You can subscribe to this list here.
2010 |
Jan
|
Feb
|
Mar
|
Apr
(4) |
May
(28) |
Jun
(12) |
Jul
(11) |
Aug
(12) |
Sep
(5) |
Oct
(19) |
Nov
(14) |
Dec
(12) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2011 |
Jan
(18) |
Feb
(30) |
Mar
(115) |
Apr
(89) |
May
(50) |
Jun
(44) |
Jul
(22) |
Aug
(13) |
Sep
(11) |
Oct
(30) |
Nov
(28) |
Dec
(39) |
2012 |
Jan
(38) |
Feb
(18) |
Mar
(43) |
Apr
(91) |
May
(108) |
Jun
(46) |
Jul
(37) |
Aug
(44) |
Sep
(33) |
Oct
(29) |
Nov
(36) |
Dec
(15) |
2013 |
Jan
(35) |
Feb
(611) |
Mar
(5) |
Apr
(55) |
May
(30) |
Jun
(28) |
Jul
(458) |
Aug
(34) |
Sep
(9) |
Oct
(39) |
Nov
(22) |
Dec
(32) |
2014 |
Jan
(16) |
Feb
(16) |
Mar
(42) |
Apr
(179) |
May
(7) |
Jun
(6) |
Jul
(9) |
Aug
|
Sep
(4) |
Oct
|
Nov
(3) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Michael P. <mic...@us...> - 2011-03-21 14:49:16
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 0f0f1798b83b01d3323cd0a9e63e5069e4fb1d4c (commit) from 476f70fbc5292378da7d7e70283b2f44aa0d9d05 (commit) - Log ----------------------------------------------------------------- commit 0f0f1798b83b01d3323cd0a9e63e5069e4fb1d4c Author: Michael P <mic...@us...> Date: Mon Mar 21 23:22:37 2011 +0900 Fix for bugs 3124253 and 3202554: Unique remote query node Postgres-XC has been implemented in a way that allowed the creation of multiple RemoteQuery nodes having the same query. This was resulting in launching several times the same query on backend nodes, making an error for queries that are internally transformed several times as a CREATE first and then ALTER for constraint treatments. In this commit, only top-level queries are allowed to create a RemoteQuery node, assuring the uniqueness of what is sent to backend nodes. Here are a couple of cases solved. For example REFERENCES: CREATE TABLE truncate_a (col1 integer primary key); CREATE TABLE trunc_b (a int REFERENCES truncate_a); or multiple schema queries: CREATE SCHEMA temp_view_test CREATE TABLE base_table (a int, id int) CREATE TABLE base_table2 (a int, id int); diff --git a/src/backend/commands/schemacmds.c b/src/backend/commands/schemacmds.c index 0b7344f..09ae5c3 100644 --- a/src/backend/commands/schemacmds.c +++ b/src/backend/commands/schemacmds.c @@ -41,7 +41,11 @@ static void AlterSchemaOwner_internal(HeapTuple tup, Relation rel, Oid newOwnerI * CREATE SCHEMA */ void +#ifdef PGXC +CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString, bool is_top_level) +#else CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString) +#endif { const char *schemaName = stmt->schemaname; const char *authId = stmt->authid; @@ -122,6 +126,14 @@ CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString) */ parsetree_list = transformCreateSchemaStmt(stmt); +#ifdef PGXC + /* + * Add a RemoteQuery node for a query at top level on a remote Coordinator + */ + if (is_top_level) + parsetree_list = AddRemoteQueryNode(parsetree_list, queryString); +#endif + /* * Execute each command contained in the CREATE SCHEMA. Since the grammar * allows only utility commands in CREATE SCHEMA, there is no need to pass diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 0ed66ed..6cfc1e6 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -278,17 +278,8 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString) stmt->distributeby->disttype = DISTTYPE_HASH; stmt->distributeby->colname = cxt.fallback_dist_col; } - /* Only a remote Coordinator is allowed to send a query to backend nodes */ - if (IS_PGXC_COORDINATOR && !IsConnFromCoord()) - { - RemoteQuery *step = makeNode(RemoteQuery); - step->combine_type = COMBINE_TYPE_SAME; - step->sql_statement = queryString; - /* This query is a DDL, Launch it on both Datanodes and Coordinators. */ - step->exec_type = EXEC_ON_ALL_NODES; - result = lappend(result, step); - } #endif + return result; } @@ -2224,17 +2215,7 @@ transformAlterTableStmt(AlterTableStmt *stmt, const char *queryString) result = lappend(cxt.blist, stmt); result = list_concat(result, cxt.alist); result = list_concat(result, save_alist); -#ifdef PGXC - if (IS_PGXC_COORDINATOR) - { - RemoteQuery *step = makeNode(RemoteQuery); - step->combine_type = COMBINE_TYPE_SAME; - step->sql_statement = queryString; - /* This query is a DDl, it is launched on both Coordinators and Datanodes. */ - step->exec_type = EXEC_ON_ALL_NODES; - result = lappend(result, step); - } -#endif + return result; } @@ -2637,4 +2618,30 @@ checkLocalFKConstraints(CreateStmtContext *cxt) } } } + +/* + * AddRemoteQueryNode + * + * Add a Remote Query node to launch on Datanodes. + * This can only be done for a query a Top Level to avoid + * duplicated queries on Datanodes. + */ +List * +AddRemoteQueryNode(List *stmts, const char *queryString) +{ + List *result = stmts; + + /* Only a remote Coordinator is allowed to send a query to backend nodes */ + if (IS_PGXC_COORDINATOR && !IsConnFromCoord()) + { + RemoteQuery *step = makeNode(RemoteQuery); + step->combine_type = COMBINE_TYPE_SAME; + step->sql_statement = queryString; + /* This query is a DDL, Launch it on both Datanodes and Coordinators. */ + step->exec_type = EXEC_ON_ALL_NODES; + result = lappend(result, step); + } + + return result; +} #endif diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index c278ea0..d06fdb2 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -592,11 +592,12 @@ standard_ProcessUtility(Node *parsetree, */ case T_CreateSchemaStmt: #ifdef PGXC - if (IS_PGXC_COORDINATOR) - ExecUtilityStmtOnNodes(queryString, NULL, false, EXEC_ON_ALL_NODES); -#endif + CreateSchemaCommand((CreateSchemaStmt *) parsetree, + queryString, isTopLevel); +#else CreateSchemaCommand((CreateSchemaStmt *) parsetree, queryString); +#endif break; case T_CreateStmt: @@ -605,11 +606,18 @@ standard_ProcessUtility(Node *parsetree, ListCell *l; Oid relOid; - /* PGXC transformCreateStmt also adds T_RemoteQuery node */ /* Run parse analysis ... */ stmts = transformCreateStmt((CreateStmt *) parsetree, queryString); +#ifdef PGXC + /* + * Add a RemoteQuery node for a query at top level on a remote Coordinator + */ + if (isTopLevel) + stmts = AddRemoteQueryNode(stmts, queryString); +#endif + /* ... and do it */ foreach(l, stmts) { @@ -879,10 +887,16 @@ standard_ProcessUtility(Node *parsetree, List *stmts; ListCell *l; - /* PGXC transformCreateStmt also adds T_RemoteQuery node */ /* Run parse analysis ... */ stmts = transformAlterTableStmt((AlterTableStmt *) parsetree, queryString); +#ifdef PGXC + /* + * Add a RemoteQuery node for a query at top level on a remote Coordinator + */ + if (isTopLevel) + stmts = AddRemoteQueryNode(stmts, queryString); +#endif /* ... and do it */ foreach(l, stmts) diff --git a/src/include/commands/schemacmds.h b/src/include/commands/schemacmds.h index 760d147..008fe41 100644 --- a/src/include/commands/schemacmds.h +++ b/src/include/commands/schemacmds.h @@ -17,9 +17,13 @@ #include "nodes/parsenodes.h" +#ifdef PGXC +extern void CreateSchemaCommand(CreateSchemaStmt *parsetree, + const char *queryString, bool is_top_level); +#else extern void CreateSchemaCommand(CreateSchemaStmt *parsetree, const char *queryString); - +#endif extern void RemoveSchemas(DropStmt *drop); extern void RemoveSchemaById(Oid schemaOid); diff --git a/src/include/parser/parse_utilcmd.h b/src/include/parser/parse_utilcmd.h index 3f9b8f9..256c583 100644 --- a/src/include/parser/parse_utilcmd.h +++ b/src/include/parser/parse_utilcmd.h @@ -27,6 +27,7 @@ extern void transformRuleStmt(RuleStmt *stmt, const char *queryString, extern List *transformCreateSchemaStmt(CreateSchemaStmt *stmt); #ifdef PGXC extern bool CheckLocalIndexColumn (char loctype, char *partcolname, char *indexcolname); +extern List *AddRemoteQueryNode(List *stmts, const char *queryString); #endif #endif /* PARSE_UTILCMD_H */ ----------------------------------------------------------------------- Summary of changes: src/backend/commands/schemacmds.c | 12 +++++++++ src/backend/parser/parse_utilcmd.c | 49 ++++++++++++++++++++--------------- src/backend/tcop/utility.c | 24 ++++++++++++++--- src/include/commands/schemacmds.h | 6 +++- src/include/parser/parse_utilcmd.h | 1 + 5 files changed, 65 insertions(+), 27 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-21 10:22:27
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 476f70fbc5292378da7d7e70283b2f44aa0d9d05 (commit) from 7aaee8d89ad4f9dd211042e65ecad68edbc1e9bc (commit) - Log ----------------------------------------------------------------- commit 476f70fbc5292378da7d7e70283b2f44aa0d9d05 Author: Michael P <mic...@us...> Date: Mon Mar 21 19:19:12 2011 +0900 Fix for bug 3141640: non column select This query was crashing: create table aa(); select * from aa; This permits to check if the target list of a table for a SELECT query is empty and if it is the case send down to Datanodes a query containing "*". Patch written by Benny Wang diff --git a/src/backend/pgxc/pool/execRemote.c b/src/backend/pgxc/pool/execRemote.c index 7f53a22..d517899 100644 --- a/src/backend/pgxc/pool/execRemote.c +++ b/src/backend/pgxc/pool/execRemote.c @@ -2800,6 +2800,11 @@ ExecInitRemoteQuery(RemoteQuery *node, EState *estate, int eflags) TupleDesc typeInfo = ExecCleanTypeFromTL(node->scan.plan.targetlist, false); ExecSetSlotDescriptor(remotestate->ss.ps.ps_ResultTupleSlot, typeInfo); } + else + { + /* In case there is no target list, force its creation */ + ExecAssignResultTypeFromTL(&remotestate->ss.ps); + } ExecInitScanTupleSlot(estate, &remotestate->ss); diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 514abdb..1da8609 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -3010,6 +3010,9 @@ get_target_list(List *targetList, deparse_context *context, char *sep; int colno; ListCell *l; +#ifdef PGXC + bool no_targetlist = true; +#endif sep = " "; colno = 0; @@ -3022,6 +3025,12 @@ get_target_list(List *targetList, deparse_context *context, if (tle->resjunk) continue; /* ignore junk entries */ +#ifdef PGXC + /* Found at least one element in the target list */ + if (no_targetlist) + no_targetlist = false; +#endif + appendStringInfoString(buf, sep); sep = ", "; colno++; @@ -3063,6 +3072,17 @@ get_target_list(List *targetList, deparse_context *context, appendStringInfo(buf, " AS %s", quote_identifier(colname)); } } + +#ifdef PGXC + /* + * Because the empty target list can generate invalid SQL + * clause. Here, just fill a '*' to process a table without + * any columns, this statement will be sent to data nodes + * and treated correctly on remote nodes. + */ + if (no_targetlist) + appendStringInfo(buf, " *"); +#endif } static void ----------------------------------------------------------------------- Summary of changes: src/backend/pgxc/pool/execRemote.c | 5 +++++ src/backend/utils/adt/ruleutils.c | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 0 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-21 09:14:52
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 7aaee8d89ad4f9dd211042e65ecad68edbc1e9bc (commit) from c739272f73a860a1c1a07ea085c47e8d4e292420 (commit) - Log ----------------------------------------------------------------- commit 7aaee8d89ad4f9dd211042e65ecad68edbc1e9bc Author: Michael P <mic...@us...> Date: Mon Mar 21 18:10:47 2011 +0900 Fix for bugs 3148479, 3140473: COPY FROM CVS HEADER, COPY TO WITH CSV QUOTE When using a CVS HEADER for COPY FROM, only data rows should be sent to Datanodes. QUOTE problem was resulting in a incorrect output for data rows using quotes. Patches written by Benny Wang diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index c4643be..15f97a1 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -3968,19 +3968,17 @@ build_copy_statement(CopyState cstate, List *attnamelist, appendStringInfoString(&cstate->query_buf, " CSV"); /* - * Only rewrite the header part for COPY FROM, - * doing that for COPY TO results in multiple headers in output + * It is not necessary to send the HEADER part to Datanodes. + * Sending data is sufficient. */ - if (cstate->header_line && is_from) - appendStringInfoString(&cstate->query_buf, " HEADER"); - if (cstate->quote && cstate->quote[0] == '"') + if (cstate->quote && cstate->quote[0] != '"') { appendStringInfoString(&cstate->query_buf, " QUOTE AS "); CopyQuoteStr(&cstate->query_buf, cstate->quote); } - if (cstate->escape && cstate->quote && cstate->escape[0] == cstate->quote[0]) + if (cstate->escape && cstate->quote && cstate->escape[0] != cstate->quote[0]) { appendStringInfoString(&cstate->query_buf, " ESCAPE AS "); CopyQuoteStr(&cstate->query_buf, cstate->escape); ----------------------------------------------------------------------- Summary of changes: src/backend/commands/copy.c | 10 ++++------ 1 files changed, 4 insertions(+), 6 deletions(-) hooks/post-receive -- Postgres-XC |
From: Pavan D. <pa...@us...> - 2011-03-18 05:43:14
|
Project "Postgres-XC". The branch, pgxc-barrier has been created at df86ba5f78e6f0a350a229ef565536ca4b5826f8 (commit) - Log ----------------------------------------------------------------- commit df86ba5f78e6f0a350a229ef565536ca4b5826f8 Author: Pavan Deolasee <pav...@gm...> Date: Tue Mar 8 16:45:12 2011 +0530 First cut implementation of BARRIER for PITR and global consistent recovery diff --git a/src/backend/access/transam/rmgr.c b/src/backend/access/transam/rmgr.c index 0273b0e..70f2e42 100644 --- a/src/backend/access/transam/rmgr.c +++ b/src/backend/access/transam/rmgr.c @@ -20,9 +20,11 @@ #include "commands/dbcommands.h" #include "commands/sequence.h" #include "commands/tablespace.h" +#ifdef PGXC +#include "pgxc/barrier.h" +#endif #include "storage/freespace.h" - const RmgrData RmgrTable[RM_MAX_ID + 1] = { {"XLOG", xlog_redo, xlog_desc, NULL, NULL, NULL}, {"Transaction", xact_redo, xact_desc, NULL, NULL, NULL}, @@ -40,4 +42,8 @@ const RmgrData RmgrTable[RM_MAX_ID + 1] = { {"Gin", gin_redo, gin_desc, gin_xlog_startup, gin_xlog_cleanup, gin_safe_restartpoint}, {"Gist", gist_redo, gist_desc, gist_xlog_startup, gist_xlog_cleanup, gist_safe_restartpoint}, {"Sequence", seq_redo, seq_desc, NULL, NULL, NULL} +#ifdef PGXC + , + {"Barrier", barrier_redo, barrier_desc, NULL, NULL, NULL} +#endif }; diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 8ff88dd..1f3b218 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -38,6 +38,7 @@ #include "funcapi.h" #include "libpq/pqsignal.h" #include "miscadmin.h" +#include "pgxc/barrier.h" #include "pgstat.h" #include "postmaster/bgwriter.h" #include "storage/bufmgr.h" @@ -166,6 +167,7 @@ static bool recoveryTargetInclusive = true; static TransactionId recoveryTargetXid; static TimestampTz recoveryTargetTime; static TimestampTz recoveryLastXTime = 0; +static char *recoveryTargetBarrierId; /* if recoveryStopsHere returns true, it saves actual stop xid/time here */ static TransactionId recoveryStopXid; @@ -4927,6 +4929,13 @@ readRecoveryCommandFile(void) ereport(LOG, (errmsg("recovery_target_inclusive = %s", tok2))); } +#ifdef PGXC + else if (strcmp(tok1, "recovery_barrier_id") == 0) + { + recoveryTarget = true; + recoveryTargetBarrierId = pstrdup(tok2); + } +#endif else ereport(FATAL, (errmsg("unrecognized recovery parameter \"%s\"", @@ -5109,11 +5118,20 @@ static bool recoveryStopsHere(XLogRecord *record, bool *includeThis) { bool stopsHere; +#ifdef PGXC + bool stopsAtThisBarrier; + char *recordBarrierId; +#endif uint8 record_info; TimestampTz recordXtime; +#ifdef PGXC + /* We only consider stoppping at COMMIT, ABORT or BARRIER records */ + if ((record->xl_rmid != RM_XACT_ID) && (record->xl_rmid != RM_BARRIER_ID)) +#else /* We only consider stopping at COMMIT or ABORT records */ if (record->xl_rmid != RM_XACT_ID) +#endif return false; record_info = record->xl_info & ~XLR_INFO_MASK; if (record_info == XLOG_XACT_COMMIT) @@ -5130,6 +5148,12 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis) recordXactAbortData = (xl_xact_abort *) XLogRecGetData(record); recordXtime = recordXactAbortData->xact_time; } +#ifdef PGXC + else if (record_info == XLOG_BARRIER_CREATE) + { + recordBarrierId = (char *) XLogRecGetData(record); + } +#endif else return false; @@ -5155,6 +5179,13 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis) if (stopsHere) *includeThis = recoveryTargetInclusive; } +#ifdef PGXC + else if (recoveryTargetBarrierId) + { + if (strcmp(recoveryTargetBarrierId, recordBarrierId) == 0) + stopsAtThisBarrier = true; + } +#endif else { /* @@ -5206,6 +5237,17 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis) if (recoveryStopAfter) recoveryLastXTime = recordXtime; } +#ifdef PGXC + else if (stopsAtThisBarrier) + { + recoveryStopTime = recordXtime; + ereport(LOG, + (errmsg("recovery stopping at barrier %s, time %s", + recoveryTargetBarrierId, + timestamptz_to_str(recoveryStopTime)))); + return true; + } +#endif else recoveryLastXTime = recordXtime; diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index 13e47e9..d980e5f 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -3592,6 +3592,18 @@ _copyValue(Value *from) return newnode; } +#ifdef PGXC +static BarrierStmt * +_copyBarrierStmt(BarrierStmt *from) +{ + BarrierStmt *newnode = makeNode(BarrierStmt); + + COPY_STRING_FIELD(id); + + return newnode; +} +#endif + /* * copyObject * @@ -4152,6 +4164,11 @@ copyObject(void *from) case T_CheckPointStmt: retval = (void *) makeNode(CheckPointStmt); break; +#ifdef PGXC + case T_BarrierStmt: + retval = _copyBarrierStmt(from); + break; +#endif case T_CreateSchemaStmt: retval = _copyCreateSchemaStmt(from); break; diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c index 32ac010..fbe5074 100644 --- a/src/backend/nodes/equalfuncs.c +++ b/src/backend/nodes/equalfuncs.c @@ -2306,6 +2306,16 @@ _equalValue(Value *a, Value *b) return true; } +#ifdef PGXC + +static bool +_equalBarrierStmt(BarrierStmt *a, BarrierStmt *b) +{ + COMPARE_STRING_FIELD(id); + return true; +} +#endif + /* * equal * returns whether two nodes are equal @@ -2744,6 +2754,11 @@ equal(void *a, void *b) case T_CheckPointStmt: retval = true; break; +#ifdef PGXC + case T_BarrierStmt: + retval = _equalBarrierStmt(a, b); + break; +#endif case T_CreateSchemaStmt: retval = _equalCreateSchemaStmt(a, b); break; diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index e1266ed..6df0582 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -215,6 +215,7 @@ static TypeName *TableFuncTypeName(List *columns); DeallocateStmt PrepareStmt ExecuteStmt DropOwnedStmt ReassignOwnedStmt AlterTSConfigurationStmt AlterTSDictionaryStmt + BarrierStmt %type <node> select_no_parens select_with_parens select_clause simple_select values_clause @@ -424,6 +425,7 @@ static TypeName *TableFuncTypeName(List *columns); %type <str> opt_existing_window_name %type <ival> opt_frame_clause frame_extent frame_bound /* PGXC_BEGIN */ +%type <str> opt_barrier_id %type <distby> OptDistributeBy /* PGXC_END */ @@ -436,12 +438,12 @@ static TypeName *TableFuncTypeName(List *columns); */ /* ordinary key words in alphabetical order */ -/* PGXC - added REPLICATION, DISTRIBUTE, MODULO and HASH */ +/* PGXC - added REPLICATION, DISTRIBUTE, MODULO, BARRIER and HASH */ %token <keyword> ABORT_P ABSOLUTE_P ACCESS ACTION ADD_P ADMIN AFTER AGGREGATE ALL ALSO ALTER ALWAYS ANALYSE ANALYZE AND ANY ARRAY AS ASC ASSERTION ASSIGNMENT ASYMMETRIC AT AUTHORIZATION - BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT + BACKWARD BARRIER BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT BOOLEAN_P BOTH BY CACHE CALLED CASCADE CASCADED CASE CAST CATALOG_P CHAIN CHAR_P @@ -636,6 +638,7 @@ stmt : | AlterUserSetStmt | AlterUserStmt | AnalyzeStmt + | BarrierStmt | CheckPointStmt | CleanConnStmt | ClosePortalStmt @@ -6506,6 +6509,28 @@ opt_name_list: ; +/* PGXC_BEGIN */ +BarrierStmt: CREATE BARRIER opt_barrier_id + { + BarrierStmt *n = makeNode(BarrierStmt); + n->id = $3; + $$ = (Node *)n; + } + ; + +opt_barrier_id: + Sconst + { + $$ = pstrdup($1); + } + | /* EMPTY */ + { + $$ = NULL; + } + ; + +/* PGXC_END */ + /***************************************************************************** * * QUERY: @@ -10289,7 +10314,7 @@ ColLabel: IDENT { $$ = $1; } /* "Unreserved" keywords --- available for use as any kind of name. */ -/* PGXC - added DISTRIBUTE, HASH, REPLICATION, MODULO */ +/* PGXC - added DISTRIBUTE, HASH, REPLICATION, MODULO, BARRIER */ unreserved_keyword: ABORT_P | ABSOLUTE_P @@ -10306,6 +10331,9 @@ unreserved_keyword: | ASSIGNMENT | AT | BACKWARD +/* PGXC_BEGIN */ + | BARRIER +/* PGXC_END */ | BEFORE | BEGIN_P | BY diff --git a/src/backend/pgxc/Makefile b/src/backend/pgxc/Makefile index eecac20..ad6bb64 100644 --- a/src/backend/pgxc/Makefile +++ b/src/backend/pgxc/Makefile @@ -11,6 +11,6 @@ subdir = src/backend/pgxc top_builddir = ../../.. include $(top_builddir)/src/Makefile.global -SUBDIRS = locator plan pool +SUBDIRS = locator plan pool barrier include $(top_srcdir)/src/backend/common.mk diff --git a/src/backend/pgxc/barrier/Makefile b/src/backend/pgxc/barrier/Makefile new file mode 100644 index 0000000..d80bbec --- /dev/null +++ b/src/backend/pgxc/barrier/Makefile @@ -0,0 +1,19 @@ +#------------------------------------------------------------------------- +# +# Makefile-- +# Makefile for pool +# +# Portions Copyright (c) 2010-2011 Nippon Telegraph and Telephone Corporation +# +# IDENTIFICATION +# $PostgreSQL$ +# +#------------------------------------------------------------------------- + +subdir = src/backend/pgxc/barrier +top_builddir = ../../../.. +include $(top_builddir)/src/Makefile.global + +OBJS = barrier.o + +include $(top_srcdir)/src/backend/common.mk diff --git a/src/backend/pgxc/barrier/barrier.c b/src/backend/pgxc/barrier/barrier.c new file mode 100644 index 0000000..3e1d7cc --- /dev/null +++ b/src/backend/pgxc/barrier/barrier.c @@ -0,0 +1,493 @@ +/*------------------------------------------------------------------------- + * + * barrier.c + * + * Barrier handling for PITR + * + * + * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group + * Portions Copyright (c) 2010-2011 Nippon Telegraph and Telephone Corporation + * + * IDENTIFICATION + * $$ + * + *------------------------------------------------------------------------- + */ + +#include "postgres.h" +#include "libpq/libpq.h" +#include "libpq/pqformat.h" +#include "pgxc/barrier.h" +#include "pgxc/execRemote.h" +#include "pgxc/locator.h" +#include "pgxc/pgxc.h" +#include "pgxc/pgxcnode.h" +#include "storage/lwlock.h" +#include "tcop/dest.h" + +static const char *generate_barrier_id(const char *id); +static PGXCNodeAllHandles *PrepareBarrier(const char *id); +static void ExecuteBarrier(const char *id); +static void EndBarrier(PGXCNodeAllHandles *handles, const char *id); + +extern void ProcessCreateBarrierPrepare(const char *id); +extern void ProcessCreateBarrierEnd(const char *id); +extern void ProcessCreateBarrierExecute(const char *id); + +/* + * Prepare ourselves for an incoming BARRIER. We must disable all new 2PC + * commits and let the ongoing commits to finish. We then remember the + * barrier id (so that it can be matched with the final END message) and + * tell the driving coordinator to proceed with the next step. + * + * A simple way to implement this is to grab a lock in an exclusive mode + * while all other backend starting a 2PC will grab the lock in shared + * mode. So as long as we hold the exclusive lock, no other backend start a + * new 2PC and there can not be any 2PC in-progress. This technique would + * rely on assumption that an exclsuive lock requester is not starved by + * share lock requesters. + * + * Note: To ensure that the 2PC are not blocked for a long time, we should + * set a timeout. The lock should be release after the timeout and the + * barrier should be canceled. + */ +void +ProcessCreateBarrierPrepare(const char *id) +{ + StringInfoData buf; + + if (!IS_PGXC_COORDINATOR || !IsConnFromCoord()) + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("The CREATE BARRIER PREPARE message is expected to " + "arrive at a coordinator from another coordinator"))); + + LWLockAcquire(BarrierLock, LW_EXCLUSIVE); + + pq_beginmessage(&buf, 'b'); + pq_sendstring(&buf, id); + pq_endmessage(&buf); + pq_flush(); + + /* + * TODO Start a timer to terminate the pending barrier after a specified + * timeout + */ +} + +/* + * Mark the completetion of an on-going barrier. We must have remembered the + * barrier ID when we received the CREATE BARRIER PREPARE command + */ +void +ProcessCreateBarrierEnd(const char *id) +{ + StringInfoData buf; + + if (!IS_PGXC_COORDINATOR || !IsConnFromCoord()) + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("The CREATE BARRIER END message is expected to " + "arrive at a coordinator from another coordinator"))); + + LWLockRelease(BarrierLock); + + pq_beginmessage(&buf, 'b'); + pq_sendstring(&buf, id); + pq_endmessage(&buf); + pq_flush(); + + /* + * TODO Stop the timer + */ +} + +/* + * Execute the CREATE BARRIER comamnd. Write a BARRIER WAL record and flush the + * WAL buffers to disk before returning to the caller. Writing the WAL record + * does not guarantee successful completion of the barrier command. + */ +void +ProcessCreateBarrierExecute(const char *id) +{ + StringInfoData buf; + + if (!IsConnFromCoord()) + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("The CREATE BARRIER EXECUTE message is expected to " + "arrive from a coordinator"))); + { + XLogRecData rdata[1]; + XLogRecPtr recptr; + + rdata[0].data = (char *) id; + rdata[0].len = strlen(id) + 1; + rdata[0].buffer = InvalidBuffer; + rdata[0].next = NULL; + + recptr = XLogInsert(RM_BARRIER_ID, XLOG_BARRIER_CREATE, rdata); + XLogFlush(recptr); + } + + pq_beginmessage(&buf, 'b'); + pq_sendstring(&buf, id); + pq_endmessage(&buf); + pq_flush(); +} + +static const char * +generate_barrier_id(const char *id) +{ + /* + * TODO If the caller can passeed a NULL value, generate an id which is + * guaranteed to be unique across the cluster. We can use a combination of + * the coordinator node id and a timestamp. This may not be complete if we + * support changing coordinator ids without initdb or the system clocks are + * modified. + * + * Another option would be to let the GTM issue globally unique barrier + * IDs. For the time being, we leave it to the user to come up with an + * unique identifier + */ + return id ? id : pstrdup("dummy_barrier_id"); +} + +static PGXCNodeAllHandles * +SendBarrierPrepareRequest(List *coords, const char *id) +{ + PGXCNodeAllHandles *coord_handles; + int conn; + int msglen; + int barrier_idlen; + + coord_handles = get_handles(NIL, coords, true); + + for (conn = 0; conn < coord_handles->co_conn_count; conn++) + { + PGXCNodeHandle *handle = coord_handles->coord_handles[conn]; + + /* Invalid connection state, return error */ + if (handle->state != DN_CONNECTION_STATE_IDLE) + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("Failed to send CREATE BARRIER PREPARE request " + "to the node"))); + + barrier_idlen = strlen(id) + 1; + + msglen = 4; /* for the length itself */ + msglen += barrier_idlen; + msglen += 1; /* for barrier command itself */ + + /* msgType + msgLen */ + if (ensure_out_buffer_capacity(handle->outEnd + 1 + msglen, handle) != 0) + { + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("Out of memory"))); + } + + handle->outBuffer[handle->outEnd++] = 'b'; + msglen = htonl(msglen); + memcpy(handle->outBuffer + handle->outEnd, &msglen, 4); + handle->outEnd += 4; + + handle->outBuffer[handle->outEnd++] = CREATE_BARRIER_PREPARE; + + memcpy(handle->outBuffer + handle->outEnd, id, barrier_idlen); + handle->outEnd += barrier_idlen; + + handle->state = DN_CONNECTION_STATE_QUERY; + + pgxc_node_flush(handle); + + /* FIXME Use the right context */ + handle->barrier_id = strdup(id); + } + + return coord_handles; +} + +static void +CheckBarrierCommandStatus(PGXCNodeAllHandles *conn_handles, const char *id, + const char *command) +{ + int conn; + int count = conn_handles->co_conn_count + conn_handles->dn_conn_count; + + elog(DEBUG2, "Check CREATE BARRIER <%s> %s command status", id, command); + + for (conn = 0; conn < count; conn++) + { + PGXCNodeHandle *handle; + + if (conn < conn_handles->co_conn_count) + handle = conn_handles->coord_handles[conn]; + else + handle = conn_handles->datanode_handles[conn - conn_handles->co_conn_count]; + + if (pgxc_node_receive(1, &handle, NULL)) + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("Failed to receive response from the remote side"))); + + if (handle_response(handle, NULL) != RESPONSE_BARRIER_OK) + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("CREATE BARRIER PREPARE command failed " + "with error %s", handle->error))); + } + + elog(DEBUG2, "Successfully completed CREATE BARRIER <%s> %s command on " + "all nodes", id, command); +} + +static void +SendBarrierEndRequest(PGXCNodeAllHandles *coord_handles, const char *id) +{ + int conn; + int msglen; + int barrier_idlen; + + elog(DEBUG2, "Sending CREATE BARRIER <%s> END command to all coordinators", id); + + for (conn = 0; conn < coord_handles->co_conn_count; conn++) + { + PGXCNodeHandle *handle = coord_handles->coord_handles[conn]; + + /* Invalid connection state, return error */ + if (handle->state != DN_CONNECTION_STATE_IDLE) + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("Failed to send CREATE BARRIER PREPARE request " + "to the node"))); + + barrier_idlen = strlen(id) + 1; + + msglen = 4; /* for the length itself */ + msglen += barrier_idlen; + msglen += 1; /* for barrier command itself */ + + /* msgType + msgLen */ + if (ensure_out_buffer_capacity(handle->outEnd + 1 + msglen, handle) != 0) + { + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("Out of memory"))); + } + + handle->outBuffer[handle->outEnd++] = 'b'; + msglen = htonl(msglen); + memcpy(handle->outBuffer + handle->outEnd, &msglen, 4); + handle->outEnd += 4; + + handle->outBuffer[handle->outEnd++] = CREATE_BARRIER_END; + + memcpy(handle->outBuffer + handle->outEnd, id, barrier_idlen); + handle->outEnd += barrier_idlen; + + handle->state = DN_CONNECTION_STATE_QUERY; + pgxc_node_flush(handle); + + /* FIXME Use the right context */ + handle->barrier_id = strdup(id); + } + +} + +/* + * Prepare all coordinators for barrier. During this step all the coordinators + * are informed to suspend any new 2PC transactions. The coordinators should + * disable new 2PC transactions and then wait for the existing transactions to + * complete. Once all "in-flight" 2PC transactions are over, the coordinators + * respond back. + * + * That completes the first step in barrier generation + * + * Any errors will be reported via ereport. + */ +static PGXCNodeAllHandles * +PrepareBarrier(const char *id) +{ + PGXCNodeAllHandles *coord_handles; + + elog(DEBUG2, "Preparing coordinators for BARRIER"); + + /* + * Send a CREATE BARRIER PREPARE message to all the coordinators. We should + * send an asynchronous request so that we can disable local commits and + * then wait for the remote coordinators to finish the work + */ + coord_handles = SendBarrierPrepareRequest(GetAllCoordNodes(), id); + + /* + * Disable local commits + */ + LWLockAcquire(BarrierLock, LW_EXCLUSIVE); + + elog(DEBUG2, "Disabled 2PC commits origniating at the diriving coordinator"); + + /* + * TODO Start a timer to cancel the barrier request in case of a timeout + */ + + /* + * Local in-flight commits are now over. Check status of the remote + * coordinators + */ + CheckBarrierCommandStatus(coord_handles, id, "PREPARE"); + + return coord_handles; +} + +/* + * Execute the barrier command on all the components, including data nodes and + * coordinators. + */ +static void +ExecuteBarrier(const char *id) +{ + List *barrierDataNodeList = GetAllDataNodes(); + List *barrierCoordList = GetAllCoordNodes(); + PGXCNodeAllHandles *conn_handles; + int conn; + int msglen; + int barrier_idlen; + + conn_handles = get_handles(barrierDataNodeList, barrierCoordList, false); + + elog(DEBUG2, "Sending CREATE BARRIER <%s> EXECUTE message to " + "data nodes and coordinator", id); + /* + * Send a CREATE BARRIER request to all the data nodes and the coordinators + */ + for (conn = 0; conn < conn_handles->co_conn_count + conn_handles->dn_conn_count; conn++) + { + PGXCNodeHandle *handle; + + if (conn < conn_handles->co_conn_count) + handle = conn_handles->coord_handles[conn]; + else + handle = conn_handles->datanode_handles[conn - conn_handles->co_conn_count]; + + /* Invalid connection state, return error */ + if (handle->state != DN_CONNECTION_STATE_IDLE) + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("Failed to send CREATE BARRIER PREPARE request " + "to the node"))); + + barrier_idlen = strlen(id) + 1; + + msglen = 4; /* for the length itself */ + msglen += barrier_idlen; + msglen += 1; /* for barrier command itself */ + + /* msgType + msgLen */ + if (ensure_out_buffer_capacity(handle->outEnd + 1 + msglen, handle) != 0) + { + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("Out of memory"))); + } + + handle->outBuffer[handle->outEnd++] = 'b'; + msglen = htonl(msglen); + memcpy(handle->outBuffer + handle->outEnd, &msglen, 4); + handle->outEnd += 4; + + handle->outBuffer[handle->outEnd++] = CREATE_BARRIER_EXECUTE; + + memcpy(handle->outBuffer + handle->outEnd, id, barrier_idlen); + handle->outEnd += barrier_idlen; + + handle->state = DN_CONNECTION_STATE_QUERY; + pgxc_node_flush(handle); + + /* FIXME Use the right context */ + handle->barrier_id = strdup(id); + } + + CheckBarrierCommandStatus(conn_handles, id, "EXECUTE"); + + /* + * Also WAL log the BARRIER locally and flush the WAL buffers to disk + */ +} + +/* + * Resume 2PC commits on the local as well as remote coordinators. + */ +static void +EndBarrier(PGXCNodeAllHandles *prepared_handles, const char *id) +{ + /* Resume 2PC locally */ + LWLockRelease(BarrierLock); + + SendBarrierEndRequest(prepared_handles, id); + + CheckBarrierCommandStatus(prepared_handles, id, "END"); +} + +void +RequestBarrier(const char *id, char *completionTag) +{ + PGXCNodeAllHandles *prepared_handles; + const char *barrier_id; + + elog(DEBUG2, "CREATE BARRIER request received"); + /* + * Ensure that we are a coordinator and the request is not from another + * coordinator + */ + if (!IS_PGXC_COORDINATOR) + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("CREATE BARRIER command must be sent to a coordinator"))); + + if (IsConnFromCoord()) + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("CREATE BARRIER command is not expected from another coordinator"))); + + /* + * Get a barrier id if the user has not supplied it + */ + barrier_id = generate_barrier_id(id); + + elog(DEBUG2, "CREATE BARRIER <%s>", barrier_id); + + /* + * Step One. Prepare all coordinators for upcoming barrier request + */ + prepared_handles = PrepareBarrier(barrier_id); + + /* + * Step two. Issue BARRIER command to all involved components, including + * coordinators and data nodes + */ + ExecuteBarrier(barrier_id); + + /* + * Step three. Inform coordinators about a successfully completed barrier + */ + EndBarrier(prepared_handles, barrier_id); + + if (completionTag) + snprintf(completionTag, COMPLETION_TAG_BUFSIZE, "BARRIER %s", barrier_id); +} + +void +barrier_redo(XLogRecPtr lsn, XLogRecord *record) +{ + /* Nothing to do */ + return; +} + +void +barrier_desc(StringInfo buf, uint8 xl_info, char *rec) +{ + Assert(xl_info == XLOG_BARRIER_CREATE); + appendStringInfo(buf, "BARRIER %s", rec); +} diff --git a/src/backend/pgxc/pool/execRemote.c b/src/backend/pgxc/pool/execRemote.c index 711cd1f..849f36b 100644 --- a/src/backend/pgxc/pool/execRemote.c +++ b/src/backend/pgxc/pool/execRemote.c @@ -1347,6 +1347,7 @@ pgxc_node_receive_responses(const int conn_count, PGXCNodeHandle ** connections, * RESPONSE_TUPLEDESC - got tuple description * RESPONSE_DATAROW - got data row * RESPONSE_COPY - got copy response + * RESPONSE_BARRIER_OK - barrier command completed successfully */ int handle_response(PGXCNodeHandle * conn, RemoteQueryState *combiner) @@ -1458,6 +1459,16 @@ handle_response(PGXCNodeHandle * conn, RemoteQueryState *combiner) #endif return result; } + +#ifdef PGXC + case 'b': + { + Assert((strncmp(msg, conn->barrier_id, msg_len) == 0)); + conn->state = DN_CONNECTION_STATE_IDLE; + return RESPONSE_BARRIER_OK; + } +#endif + case 'I': /* EmptyQuery */ default: /* sync lost? */ diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 9615b52..b06b7bf 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -78,6 +78,7 @@ #include "access/gtm.h" /* PGXC_COORD */ #include "pgxc/execRemote.h" +#include "pgxc/barrier.h" #include "pgxc/planner.h" #include "pgxc/pgxcnode.h" #include "commands/copy.h" @@ -430,6 +431,7 @@ SocketBackend(StringInfo inBuf) case 'g': /* GXID */ case 's': /* Snapshot */ case 't': /* Timestamp */ + case 'b': /* Barrier */ break; #endif @@ -4031,6 +4033,37 @@ PostgresMain(int argc, char *argv[], const char *username) */ SetCurrentGTMDeltaTimestamp(timestamp); break; + + case 'b': /* barrier */ + { + int command; + char *id; + + command = pq_getmsgbyte(&input_message); + id = pq_getmsgstring(&input_message); + pq_getmsgend(&input_message); + + switch (command) + { + case CREATE_BARRIER_PREPARE: + ProcessCreateBarrierPrepare(id); + break; + + case CREATE_BARRIER_END: + ProcessCreateBarrierEnd(id); + break; + + case CREATE_BARRIER_EXECUTE: + ProcessCreateBarrierExecute(id); + break; + + default: + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("Invalid command received"))); + } + } + break; #endif /* PGXC */ default: diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index 065d880..bd13ce3 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -58,6 +58,7 @@ #include "utils/syscache.h" #ifdef PGXC +#include "pgxc/barrier.h" #include "pgxc/locator.h" #include "pgxc/pgxc.h" #include "pgxc/planner.h" @@ -1347,6 +1348,12 @@ ProcessUtility(Node *parsetree, #endif break; +#ifdef PGXC + case T_BarrierStmt: + RequestBarrier(((BarrierStmt *) parsetree)->id, completionTag); + break; +#endif + case T_ReindexStmt: { ReindexStmt *stmt = (ReindexStmt *) parsetree; @@ -2320,6 +2327,12 @@ CreateCommandTag(Node *parsetree) tag = "CHECKPOINT"; break; +#ifdef PGXC + case T_BarrierStmt: + tag = "BARRIER"; + break; +#endif + case T_ReindexStmt: tag = "REINDEX"; break; diff --git a/src/include/access/rmgr.h b/src/include/access/rmgr.h index 5702f5f..a46e7fe 100644 --- a/src/include/access/rmgr.h +++ b/src/include/access/rmgr.h @@ -30,6 +30,11 @@ typedef uint8 RmgrId; #define RM_GIN_ID 13 #define RM_GIST_ID 14 #define RM_SEQ_ID 15 +#ifdef PGXC +#define RM_BARRIER_ID 16 +#define RM_MAX_ID RM_BARRIER_ID +#else #define RM_MAX_ID RM_SEQ_ID +#endif #endif /* RMGR_H */ diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h index 6776c25..e4ff851 100644 --- a/src/include/nodes/nodes.h +++ b/src/include/nodes/nodes.h @@ -319,6 +319,9 @@ typedef enum NodeTag T_ConstraintsSetStmt, T_ReindexStmt, T_CheckPointStmt, +#ifdef PGXC + T_BarrierStmt, +#endif T_CreateSchemaStmt, T_AlterDatabaseStmt, T_AlterDatabaseSetStmt, diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index 951484c..7398649 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -2201,6 +2201,19 @@ typedef struct VacuumStmt List *va_cols; /* list of column names, or NIL for all */ } VacuumStmt; +#ifdef PGXC +/* + * ---------------------- + * Barrier Statement + */ +typedef struct BarrierStmt +{ + NodeTag type; + const char *id; /* User supplied barrier id, if any */ +} BarrierStmt; + +#endif + /* ---------------------- * Explain Statement * ---------------------- diff --git a/src/include/parser/kwlist.h b/src/include/parser/kwlist.h index 2c84923..6993eee 100644 --- a/src/include/parser/kwlist.h +++ b/src/include/parser/kwlist.h @@ -52,6 +52,9 @@ PG_KEYWORD("asymmetric", ASYMMETRIC, RESERVED_KEYWORD) PG_KEYWORD("at", AT, UNRESERVED_KEYWORD) PG_KEYWORD("authorization", AUTHORIZATION, TYPE_FUNC_NAME_KEYWORD) PG_KEYWORD("backward", BACKWARD, UNRESERVED_KEYWORD) +#ifdef PGXC +PG_KEYWORD("barrier", BARRIER, UNRESERVED_KEYWORD) +#endif PG_KEYWORD("before", BEFORE, UNRESERVED_KEYWORD) PG_KEYWORD("begin", BEGIN_P, UNRESERVED_KEYWORD) PG_KEYWORD("between", BETWEEN, TYPE_FUNC_NAME_KEYWORD) diff --git a/src/include/pgxc/barrier.h b/src/include/pgxc/barrier.h new file mode 100644 index 0000000..37b5067 --- /dev/null +++ b/src/include/pgxc/barrier.h @@ -0,0 +1,40 @@ +/*------------------------------------------------------------------------- + * + * barrier.h + * + * Definitions for the PITR barrier handling + * + * + * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group + * Portions Copyright (c) 2010-2011 Nippon Telegraph and Telephone Corporation + * + * IDENTIFICATION + * $$ + * + *------------------------------------------------------------------------- + */ + +#ifndef BARRIER_H +#define BARRIER_H + +#include "access/xlog.h" +#include "access/xlogdefs.h" + +#define CREATE_BARRIER_PREPARE 'P' +#define CREATE_BARRIER_EXECUTE 'X' +#define CREATE_BARRIER_END 'E' + +#define CREATE_BARRIER_PREPARE_DONE 'p' +#define CREATE_BARRIER_EXECUTE_DONE 'x' + +typedef struct xl_barrier +{ + char barrier_id[1]; /* variable length data follows */ +} xl_barrier; + +#define XLOG_BARRIER_CREATE 0x00 + +extern void RequestBarrier(const char *id, char *completionTag); +extern void barrier_redo(XLogRecPtr lsn, XLogRecord *record); +extern void barrier_desc(StringInfo buf, uint8 xl_info, char *rec); +#endif diff --git a/src/include/pgxc/execRemote.h b/src/include/pgxc/execRemote.h index 23ea4a8..e9f000f 100644 --- a/src/include/pgxc/execRemote.h +++ b/src/include/pgxc/execRemote.h @@ -36,6 +36,7 @@ #define RESPONSE_TUPDESC 2 #define RESPONSE_DATAROW 3 #define RESPONSE_COPY 4 +#define RESPONSE_BARRIER_OK 5 typedef enum { diff --git a/src/include/pgxc/pgxcnode.h b/src/include/pgxc/pgxcnode.h index f8ac7c6..38fe895 100644 --- a/src/include/pgxc/pgxcnode.h +++ b/src/include/pgxc/pgxcnode.h @@ -66,6 +66,7 @@ struct pgxc_node_handle #ifdef DN_CONNECTION_DEBUG bool have_row_desc; #endif + char *barrier_id; char *error; /* Output buffer */ char *outBuffer; diff --git a/src/include/storage/lwlock.h b/src/include/storage/lwlock.h index 0548159..398ebd9 100644 --- a/src/include/storage/lwlock.h +++ b/src/include/storage/lwlock.h @@ -69,6 +69,7 @@ typedef enum LWLockId SyncScanLock, #ifdef PGXC AnalyzeProcArrayLock, + BarrierLock, #endif /* Individual lock IDs end here */ FirstBufMappingLock, ----------------------------------------------------------------------- hooks/post-receive -- Postgres-XC |
From: Abbas B. <ga...@us...> - 2011-03-17 16:25:19
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via c739272f73a860a1c1a07ea085c47e8d4e292420 (commit) from 0115aacecb33438da33b51e7761498de6a854ba3 (commit) - Log ----------------------------------------------------------------- commit c739272f73a860a1c1a07ea085c47e8d4e292420 Author: Abbas <abb...@en...> Date: Thu Mar 17 21:23:30 2011 +0500 Add alternate expected output file to fix regression falilure of numeric.sql diff --git a/src/test/regress/expected/numeric_1.out b/src/test/regress/expected/numeric_1.out new file mode 100644 index 0000000..89c19c9 --- /dev/null +++ b/src/test/regress/expected/numeric_1.out @@ -0,0 +1,1357 @@ +-- +-- NUMERIC +-- +CREATE TABLE num_data (id int4, val numeric(210,10)); +CREATE TABLE num_exp_add (id1 int4, id2 int4, expected numeric(210,10)); +CREATE TABLE num_exp_sub (id1 int4, id2 int4, expected numeric(210,10)); +CREATE TABLE num_exp_div (id1 int4, id2 int4, expected numeric(210,10)); +CREATE TABLE num_exp_mul (id1 int4, id2 int4, expected numeric(210,10)); +CREATE TABLE num_exp_sqrt (id int4, expected numeric(210,10)); +CREATE TABLE num_exp_ln (id int4, expected numeric(210,10)); +CREATE TABLE num_exp_log10 (id int4, expected numeric(210,10)); +CREATE TABLE num_exp_power_10_ln (id int4, expected numeric(210,10)); +CREATE TABLE num_result (id1 int4, id2 int4, result numeric(210,10)); +-- ****************************** +-- * The following EXPECTED results are computed by bc(1) +-- * with a scale of 200 +-- ****************************** +BEGIN TRANSACTION; +INSERT INTO num_exp_add VALUES (0,0,'0'); +INSERT INTO num_exp_sub VALUES (0,0,'0'); +INSERT INTO num_exp_mul VALUES (0,0,'0'); +INSERT INTO num_exp_div VALUES (0,0,'NaN'); +INSERT INTO num_exp_add VALUES (0,1,'0'); +INSERT INTO num_exp_sub VALUES (0,1,'0'); +INSERT INTO num_exp_mul VALUES (0,1,'0'); +INSERT INTO num_exp_div VALUES (0,1,'NaN'); +INSERT INTO num_exp_add VALUES (0,2,'-34338492.215397047'); +INSERT INTO num_exp_sub VALUES (0,2,'34338492.215397047'); +INSERT INTO num_exp_mul VALUES (0,2,'0'); +INSERT INTO num_exp_div VALUES (0,2,'0'); +INSERT INTO num_exp_add VALUES (0,3,'4.31'); +INSERT INTO num_exp_sub VALUES (0,3,'-4.31'); +INSERT INTO num_exp_mul VALUES (0,3,'0'); +INSERT INTO num_exp_div VALUES (0,3,'0'); +INSERT INTO num_exp_add VALUES (0,4,'7799461.4119'); +INSERT INTO num_exp_sub VALUES (0,4,'-7799461.4119'); +INSERT INTO num_exp_mul VALUES (0,4,'0'); +INSERT INTO num_exp_div VALUES (0,4,'0'); +INSERT INTO num_exp_add VALUES (0,5,'16397.038491'); +INSERT INTO num_exp_sub VALUES (0,5,'-16397.038491'); +INSERT INTO num_exp_mul VALUES (0,5,'0'); +INSERT INTO num_exp_div VALUES (0,5,'0'); +INSERT INTO num_exp_add VALUES (0,6,'93901.57763026'); +INSERT INTO num_exp_sub VALUES (0,6,'-93901.57763026'); +INSERT INTO num_exp_mul VALUES (0,6,'0'); +INSERT INTO num_exp_div VALUES (0,6,'0'); +INSERT INTO num_exp_add VALUES (0,7,'-83028485'); +INSERT INTO num_exp_sub VALUES (0,7,'83028485'); +INSERT INTO num_exp_mul VALUES (0,7,'0'); +INSERT INTO num_exp_div VALUES (0,7,'0'); +INSERT INTO num_exp_add VALUES (0,8,'74881'); +INSERT INTO num_exp_sub VALUES (0,8,'-74881'); +INSERT INTO num_exp_mul VALUES (0,8,'0'); +INSERT INTO num_exp_div VALUES (0,8,'0'); +INSERT INTO num_exp_add VALUES (0,9,'-24926804.045047420'); +INSERT INTO num_exp_sub VALUES (0,9,'24926804.045047420'); +INSERT INTO num_exp_mul VALUES (0,9,'0'); +INSERT INTO num_exp_div VALUES (0,9,'0'); +INSERT INTO num_exp_add VALUES (1,0,'0'); +INSERT INTO num_exp_sub VALUES (1,0,'0'); +INSERT INTO num_exp_mul VALUES (1,0,'0'); +INSERT INTO num_exp_div VALUES (1,0,'NaN'); +INSERT INTO num_exp_add VALUES (1,1,'0'); +INSERT INTO num_exp_sub VALUES (1,1,'0'); +INSERT INTO num_exp_mul VALUES (1,1,'0'); +INSERT INTO num_exp_div VALUES (1,1,'NaN'); +INSERT INTO num_exp_add VALUES (1,2,'-34338492.215397047'); +INSERT INTO num_exp_sub VALUES (1,2,'34338492.215397047'); +INSERT INTO num_exp_mul VALUES (1,2,'0'); +INSERT INTO num_exp_div VALUES (1,2,'0'); +INSERT INTO num_exp_add VALUES (1,3,'4.31'); +INSERT INTO num_exp_sub VALUES (1,3,'-4.31'); +INSERT INTO num_exp_mul VALUES (1,3,'0'); +INSERT INTO num_exp_div VALUES (1,3,'0'); +INSERT INTO num_exp_add VALUES (1,4,'7799461.4119'); +INSERT INTO num_exp_sub VALUES (1,4,'-7799461.4119'); +INSERT INTO num_exp_mul VALUES (1,4,'0'); +INSERT INTO num_exp_div VALUES (1,4,'0'); +INSERT INTO num_exp_add VALUES (1,5,'16397.038491'); +INSERT INTO num_exp_sub VALUES (1,5,'-16397.038491'); +INSERT INTO num_exp_mul VALUES (1,5,'0'); +INSERT INTO num_exp_div VALUES (1,5,'0'); +INSERT INTO num_exp_add VALUES (1,6,'93901.57763026'); +INSERT INTO num_exp_sub VALUES (1,6,'-93901.57763026'); +INSERT INTO num_exp_mul VALUES (1,6,'0'); +INSERT INTO num_exp_div VALUES (1,6,'0'); +INSERT INTO num_exp_add VALUES (1,7,'-83028485'); +INSERT INTO num_exp_sub VALUES (1,7,'83028485'); +INSERT INTO num_exp_mul VALUES (1,7,'0'); +INSERT INTO num_exp_div VALUES (1,7,'0'); +INSERT INTO num_exp_add VALUES (1,8,'74881'); +INSERT INTO num_exp_sub VALUES (1,8,'-74881'); +INSERT INTO num_exp_mul VALUES (1,8,'0'); +INSERT INTO num_exp_div VALUES (1,8,'0'); +INSERT INTO num_exp_add VALUES (1,9,'-24926804.045047420'); +INSERT INTO num_exp_sub VALUES (1,9,'24926804.045047420'); +INSERT INTO num_exp_mul VALUES (1,9,'0'); +INSERT INTO num_exp_div VALUES (1,9,'0'); +INSERT INTO num_exp_add VALUES (2,0,'-34338492.215397047'); +INSERT INTO num_exp_sub VALUES (2,0,'-34338492.215397047'); +INSERT INTO num_exp_mul VALUES (2,0,'0'); +INSERT INTO num_exp_div VALUES (2,0,'NaN'); +INSERT INTO num_exp_add VALUES (2,1,'-34338492.215397047'); +INSERT INTO num_exp_sub VALUES (2,1,'-34338492.215397047'); +INSERT INTO num_exp_mul VALUES (2,1,'0'); +INSERT INTO num_exp_div VALUES (2,1,'NaN'); +INSERT INTO num_exp_add VALUES (2,2,'-68676984.430794094'); +INSERT INTO num_exp_sub VALUES (2,2,'0'); +INSERT INTO num_exp_mul VALUES (2,2,'1179132047626883.596862135856320209'); +INSERT INTO num_exp_div VALUES (2,2,'1.00000000000000000000'); +INSERT INTO num_exp_add VALUES (2,3,'-34338487.905397047'); +INSERT INTO num_exp_sub VALUES (2,3,'-34338496.525397047'); +INSERT INTO num_exp_mul VALUES (2,3,'-147998901.44836127257'); +INSERT INTO num_exp_div VALUES (2,3,'-7967167.56737750510440835266'); +INSERT INTO num_exp_add VALUES (2,4,'-26539030.803497047'); +INSERT INTO num_exp_sub VALUES (2,4,'-42137953.627297047'); +INSERT INTO num_exp_mul VALUES (2,4,'-267821744976817.8111137106593'); +INSERT INTO num_exp_div VALUES (2,4,'-4.40267480046830116685'); +INSERT INTO num_exp_add VALUES (2,5,'-34322095.176906047'); +INSERT INTO num_exp_sub VALUES (2,5,'-34354889.253888047'); +INSERT INTO num_exp_mul VALUES (2,5,'-563049578578.769242506736077'); +INSERT INTO num_exp_div VALUES (2,5,'-2094.18866914563535496429'); +INSERT INTO num_exp_add VALUES (2,6,'-34244590.637766787'); +INSERT INTO num_exp_sub VALUES (2,6,'-34432393.793027307'); +INSERT INTO num_exp_mul VALUES (2,6,'-3224438592470.18449811926184222'); +INSERT INTO num_exp_div VALUES (2,6,'-365.68599891479766440940'); +INSERT INTO num_exp_add VALUES (2,7,'-117366977.215397047'); +INSERT INTO num_exp_sub VALUES (2,7,'48689992.784602953'); +INSERT INTO num_exp_mul VALUES (2,7,'2851072985828710.485883795'); +INSERT INTO num_exp_div VALUES (2,7,'.41357483778485235518'); +INSERT INTO num_exp_add VALUES (2,8,'-34263611.215397047'); +INSERT INTO num_exp_sub VALUES (2,8,'-34413373.215397047'); +INSERT INTO num_exp_mul VALUES (2,8,'-2571300635581.146276407'); +INSERT INTO num_exp_div VALUES (2,8,'-458.57416721727870888476'); +INSERT INTO num_exp_add VALUES (2,9,'-59265296.260444467'); +INSERT INTO num_exp_sub VALUES (2,9,'-9411688.170349627'); +INSERT INTO num_exp_mul VALUES (2,9,'855948866655588.453741509242968740'); +INSERT INTO num_exp_div VALUES (2,9,'1.37757299946438931811'); +INSERT INTO num_exp_add VALUES (3,0,'4.31'); +INSERT INTO num_exp_sub VALUES (3,0,'4.31'); +INSERT INTO num_exp_mul VALUES (3,0,'0'); +INSERT INTO num_exp_div VALUES (3,0,'NaN'); +INSERT INTO num_exp_add VALUES (3,1,'4.31'); +INSERT INTO num_exp_sub VALUES (3,1,'4.31'); +INSERT INTO num_exp_mul VALUES (3,1,'0'); +INSERT INTO num_exp_div VALUES (3,1,'NaN'); +INSERT INTO num_exp_add VALUES (3,2,'-34338487.905397047'); +INSERT INTO num_exp_sub VALUES (3,2,'34338496.525397047'); +INSERT INTO num_exp_mul VALUES (3,2,'-147998901.44836127257'); +INSERT INTO num_exp_div VALUES (3,2,'-.00000012551512084352'); +INSERT INTO num_exp_add VALUES (3,3,'8.62'); +INSERT INTO num_exp_sub VALUES (3,3,'0'); +INSERT INTO num_exp_mul VALUES (3,3,'18.5761'); +INSERT INTO num_exp_div VALUES (3,3,'1.00000000000000000000'); +INSERT INTO num_exp_add VALUES (3,4,'7799465.7219'); +INSERT INTO num_exp_sub VALUES (3,4,'-7799457.1019'); +INSERT INTO num_exp_mul VALUES (3,4,'33615678.685289'); +INSERT INTO num_exp_div VALUES (3,4,'.00000055260225961552'); +INSERT INTO num_exp_add VALUES (3,5,'16401.348491'); +INSERT INTO num_exp_sub VALUES (3,5,'-16392.728491'); +INSERT INTO num_exp_mul VALUES (3,5,'70671.23589621'); +INSERT INTO num_exp_div VALUES (3,5,'.00026285234387695504'); +INSERT INTO num_exp_add VALUES (3,6,'93905.88763026'); +INSERT INTO num_exp_sub VALUES (3,6,'-93897.26763026'); +INSERT INTO num_exp_mul VALUES (3,6,'404715.7995864206'); +INSERT INTO num_exp_div VALUES (3,6,'.00004589912234457595'); +INSERT INTO num_exp_add VALUES (3,7,'-83028480.69'); +INSERT INTO num_exp_sub VALUES (3,7,'83028489.31'); +INSERT INTO num_exp_mul VALUES (3,7,'-357852770.35'); +INSERT INTO num_exp_div VALUES (3,7,'-.00000005190989574240'); +INSERT INTO num_exp_add VALUES (3,8,'74885.31'); +INSERT INTO num_exp_sub VALUES (3,8,'-74876.69'); +INSERT INTO num_exp_mul VALUES (3,8,'322737.11'); +INSERT INTO num_exp_div VALUES (3,8,'.00005755799201399553'); +INSERT INTO num_exp_add VALUES (3,9,'-24926799.735047420'); +INSERT INTO num_exp_sub VALUES (3,9,'24926808.355047420'); +INSERT INTO num_exp_mul VALUES (3,9,'-107434525.43415438020'); +INSERT INTO num_exp_div VALUES (3,9,'-.00000017290624149854'); +INSERT INTO num_exp_add VALUES (4,0,'7799461.4119'); +INSERT INTO num_exp_sub VALUES (4,0,'7799461.4119'); +INSERT INTO num_exp_mul VALUES (4,0,'0'); +INSERT INTO num_exp_div VALUES (4,0,'NaN'); +INSERT INTO num_exp_add VALUES (4,1,'7799461.4119'); +INSERT INTO num_exp_sub VALUES (4,1,'7799461.4119'); +INSERT INTO num_exp_mul VALUES (4,1,'0'); +INSERT INTO num_exp_div VALUES (4,1,'NaN'); +INSERT INTO num_exp_add VALUES (4,2,'-26539030.803497047'); +INSERT INTO num_exp_sub VALUES (4,2,'42137953.627297047'); +INSERT INTO num_exp_mul VALUES (4,2,'-267821744976817.8111137106593'); +INSERT INTO num_exp_div VALUES (4,2,'-.22713465002993920385'); +INSERT INTO num_exp_add VALUES (4,3,'7799465.7219'); +INSERT INTO num_exp_sub VALUES (4,3,'7799457.1019'); +INSERT INTO num_exp_mul VALUES (4,3,'33615678.685289'); +INSERT INTO num_exp_div VALUES (4,3,'1809619.81714617169373549883'); +INSERT INTO num_exp_add VALUES (4,4,'15598922.8238'); +INSERT INTO num_exp_sub VALUES (4,4,'0'); +INSERT INTO num_exp_mul VALUES (4,4,'60831598315717.14146161'); +INSERT INTO num_exp_div VALUES (4,4,'1.00000000000000000000'); +INSERT INTO num_exp_add VALUES (4,5,'7815858.450391'); +INSERT INTO num_exp_sub VALUES (4,5,'7783064.373409'); +INSERT INTO num_exp_mul VALUES (4,5,'127888068979.9935054429'); +INSERT INTO num_exp_div VALUES (4,5,'475.66281046305802686061'); +INSERT INTO num_exp_add VALUES (4,6,'7893362.98953026'); +INSERT INTO num_exp_sub VALUES (4,6,'7705559.83426974'); +INSERT INTO num_exp_mul VALUES (4,6,'732381731243.745115764094'); +INSERT INTO num_exp_div VALUES (4,6,'83.05996138436129499606'); +INSERT INTO num_exp_add VALUES (4,7,'-75229023.5881'); +INSERT INTO num_exp_sub VALUES (4,7,'90827946.4119'); +INSERT INTO num_exp_mul VALUES (4,7,'-647577464846017.9715'); +INSERT INTO num_exp_div VALUES (4,7,'-.09393717604145131637'); +INSERT INTO num_exp_add VALUES (4,8,'7874342.4119'); +INSERT INTO num_exp_sub VALUES (4,8,'7724580.4119'); +INSERT INTO num_exp_mul VALUES (4,8,'584031469984.4839'); +INSERT INTO num_exp_div VALUES (4,8,'104.15808298366741897143'); +INSERT INTO num_exp_add VALUES (4,9,'-17127342.633147420'); +INSERT INTO num_exp_sub VALUES (4,9,'32726265.456947420'); +INSERT INTO num_exp_mul VALUES (4,9,'-194415646271340.1815956522980'); +INSERT INTO num_exp_div VALUES (4,9,'-.31289456112403769409'); +INSERT INTO num_exp_add VALUES (5,0,'16397.038491'); +INSERT INTO num_exp_sub VALUES (5,0,'16397.038491'); +INSERT INTO num_exp_mul VALUES (5,0,'0'); +INSERT INTO num_exp_div VALUES (5,0,'NaN'); +INSERT INTO num_exp_add VALUES (5,1,'16397.038491'); +INSERT INTO num_exp_sub VALUES (5,1,'16397.038491'); +INSERT INTO num_exp_mul VALUES (5,1,'0'); +INSERT INTO num_exp_div VALUES (5,1,'NaN'); +INSERT INTO num_exp_add VALUES (5,2,'-34322095.176906047'); +INSERT INTO num_exp_sub VALUES (5,2,'34354889.253888047'); +INSERT INTO num_exp_mul VALUES (5,2,'-563049578578.769242506736077'); +INSERT INTO num_exp_div VALUES (5,2,'-.00047751189505192446'); +INSERT INTO num_exp_add VALUES (5,3,'16401.348491'); +INSERT INTO num_exp_sub VALUES (5,3,'16392.728491'); +INSERT INTO num_exp_mul VALUES (5,3,'70671.23589621'); +INSERT INTO num_exp_div VALUES (5,3,'3804.41728329466357308584'); +INSERT INTO num_exp_add VALUES (5,4,'7815858.450391'); +INSERT INTO num_exp_sub VALUES (5,4,'-7783064.373409'); +INSERT INTO num_exp_mul VALUES (5,4,'127888068979.9935054429'); +INSERT INTO num_exp_div VALUES (5,4,'.00210232958726897192'); +INSERT INTO num_exp_add VALUES (5,5,'32794.076982'); +INSERT INTO num_exp_sub VALUES (5,5,'0'); +INSERT INTO num_exp_mul VALUES (5,5,'268862871.275335557081'); +INSERT INTO num_exp_div VALUES (5,5,'1.00000000000000000000'); +INSERT INTO num_exp_add VALUES (5,6,'110298.61612126'); +INSERT INTO num_exp_sub VALUES (5,6,'-77504.53913926'); +INSERT INTO num_exp_mul VALUES (5,6,'1539707782.76899778633766'); +INSERT INTO num_exp_div VALUES (5,6,'.17461941433576102689'); +INSERT INTO num_exp_add VALUES (5,7,'-83012087.961509'); +INSERT INTO num_exp_sub VALUES (5,7,'83044882.038491'); +INSERT INTO num_exp_mul VALUES (5,7,'-1361421264394.416135'); +INSERT INTO num_exp_div VALUES (5,7,'-.00019748690453643710'); +INSERT INTO num_exp_add VALUES (5,8,'91278.038491'); +INSERT INTO num_exp_sub VALUES (5,8,'-58483.961509'); +INSERT INTO num_exp_mul VALUES (5,8,'1227826639.244571'); +INSERT INTO num_exp_div VALUES (5,8,'.21897461960978085228'); +INSERT INTO num_exp_add VALUES (5,9,'-24910407.006556420'); +INSERT INTO num_exp_sub VALUES (5,9,'24943201.083538420'); +INSERT INTO num_exp_mul VALUES (5,9,'-408725765384.257043660243220'); +INSERT INTO num_exp_div VALUES (5,9,'-.00065780749354660427'); +INSERT INTO num_exp_add VALUES (6,0,'93901.57763026'); +INSERT INTO num_exp_sub VALUES (6,0,'93901.57763026'); +INSERT INTO num_exp_mul VALUES (6,0,'0'); +INSERT INTO num_exp_div VALUES (6,0,'NaN'); +INSERT INTO num_exp_add VALUES (6,1,'93901.57763026'); +INSERT INTO num_exp_sub VALUES (6,1,'93901.57763026'); +INSERT INTO num_exp_mul VALUES (6,1,'0'); +INSERT INTO num_exp_div VALUES (6,1,'NaN'); +INSERT INTO num_exp_add VALUES (6,2,'-34244590.637766787'); +INSERT INTO num_exp_sub VALUES (6,2,'34432393.793027307'); +INSERT INTO num_exp_mul VALUES (6,2,'-3224438592470.18449811926184222'); +INSERT INTO num_exp_div VALUES (6,2,'-.00273458651128995823'); +INSERT INTO num_exp_add VALUES (6,3,'93905.88763026'); +INSERT INTO num_exp_sub VALUES (6,3,'93897.26763026'); +INSERT INTO num_exp_mul VALUES (6,3,'404715.7995864206'); +INSERT INTO num_exp_div VALUES (6,3,'21786.90896293735498839907'); +INSERT INTO num_exp_add VALUES (6,4,'7893362.98953026'); +INSERT INTO num_exp_sub VALUES (6,4,'-7705559.83426974'); +INSERT INTO num_exp_mul VALUES (6,4,'732381731243.745115764094'); +INSERT INTO num_exp_div VALUES (6,4,'.01203949512295682469'); +INSERT INTO num_exp_add VALUES (6,5,'110298.61612126'); +INSERT INTO num_exp_sub VALUES (6,5,'77504.53913926'); +INSERT INTO num_exp_mul VALUES (6,5,'1539707782.76899778633766'); +INSERT INTO num_exp_div VALUES (6,5,'5.72674008674192359679'); +INSERT INTO num_exp_add VALUES (6,6,'187803.15526052'); +INSERT INTO num_exp_sub VALUES (6,6,'0'); +INSERT INTO num_exp_mul VALUES (6,6,'8817506281.4517452372676676'); +INSERT INTO num_exp_div VALUES (6,6,'1.00000000000000000000'); +INSERT INTO num_exp_add VALUES (6,7,'-82934583.42236974'); +INSERT INTO num_exp_sub VALUES (6,7,'83122386.57763026'); +INSERT INTO num_exp_mul VALUES (6,7,'-7796505729750.37795610'); +INSERT INTO num_exp_div VALUES (6,7,'-.00113095617281538980'); +INSERT INTO num_exp_add VALUES (6,8,'168782.57763026'); +INSERT INTO num_exp_sub VALUES (6,8,'19020.57763026'); +INSERT INTO num_exp_mul VALUES (6,8,'7031444034.53149906'); +INSERT INTO num_exp_div VALUES (6,8,'1.25401073209839612184'); +INSERT INTO num_exp_add VALUES (6,9,'-24832902.467417160'); +INSERT INTO num_exp_sub VALUES (6,9,'25020705.622677680'); +INSERT INTO num_exp_mul VALUES (6,9,'-2340666225110.29929521292692920'); +INSERT INTO num_exp_div VALUES (6,9,'-.00376709254265256789'); +INSERT INTO num_exp_add VALUES (7,0,'-83028485'); +INSERT INTO num_exp_sub VALUES (7,0,'-83028485'); +INSERT INTO num_exp_mul VALUES (7,0,'0'); +INSERT INTO num_exp_div VALUES (7,0,'NaN'); +INSERT INTO num_exp_add VALUES (7,1,'-83028485'); +INSERT INTO num_exp_sub VALUES (7,1,'-83028485'); +INSERT INTO num_exp_mul VALUES (7,1,'0'); +INSERT INTO num_exp_div VALUES (7,1,'NaN'); +INSERT INTO num_exp_add VALUES (7,2,'-117366977.215397047'); +INSERT INTO num_exp_sub VALUES (7,2,'-48689992.784602953'); +INSERT INTO num_exp_mul VALUES (7,2,'2851072985828710.485883795'); +INSERT INTO num_exp_div VALUES (7,2,'2.41794207151503385700'); +INSERT INTO num_exp_add VALUES (7,3,'-83028480.69'); +INSERT INTO num_exp_sub VALUES (7,3,'-83028489.31'); +INSERT INTO num_exp_mul VALUES (7,3,'-357852770.35'); +INSERT INTO num_exp_div VALUES (7,3,'-19264149.65197215777262180974'); +INSERT INTO num_exp_add VALUES (7,4,'-75229023.5881'); +INSERT INTO num_exp_sub VALUES (7,4,'-90827946.4119'); +INSERT INTO num_exp_mul VALUES (7,4,'-647577464846017.9715'); +INSERT INTO num_exp_div VALUES (7,4,'-10.64541262725136247686'); +INSERT INTO num_exp_add VALUES (7,5,'-83012087.961509'); +INSERT INTO num_exp_sub VALUES (7,5,'-83044882.038491'); +INSERT INTO num_exp_mul VALUES (7,5,'-1361421264394.416135'); +INSERT INTO num_exp_div VALUES (7,5,'-5063.62688881730941836574'); +INSERT INTO num_exp_add VALUES (7,6,'-82934583.42236974'); +INSERT INTO num_exp_sub VALUES (7,6,'-83122386.57763026'); +INSERT INTO num_exp_mul VALUES (7,6,'-7796505729750.37795610'); +INSERT INTO num_exp_div VALUES (7,6,'-884.20756174009028770294'); +INSERT INTO num_exp_add VALUES (7,7,'-166056970'); +INSERT INTO num_exp_sub VALUES (7,7,'0'); +INSERT INTO num_exp_mul VALUES (7,7,'6893729321395225'); +INSERT INTO num_exp_div VALUES (7,7,'1.00000000000000000000'); +INSERT INTO num_exp_add VALUES (7,8,'-82953604'); +INSERT INTO num_exp_sub VALUES (7,8,'-83103366'); +INSERT INTO num_exp_mul VALUES (7,8,'-6217255985285'); +INSERT INTO num_exp_div VALUES (7,8,'-1108.80577182462841041118'); +INSERT INTO num_exp_add VALUES (7,9,'-107955289.045047420'); +INSERT INTO num_exp_sub VALUES (7,9,'-58101680.954952580'); +INSERT INTO num_exp_mul VALUES (7,9,'2069634775752159.035758700'); +INSERT INTO num_exp_div VALUES (7,9,'3.33089171198810413382'); +INSERT INTO num_exp_add VALUES (8,0,'74881'); +INSERT INTO num_exp_sub VALUES (8,0,'74881'); +INSERT INTO num_exp_mul VALUES (8,0,'0'); +INSERT INTO num_exp_div VALUES (8,0,'NaN'); +INSERT INTO num_exp_add VALUES (8,1,'74881'); +INSERT INTO num_exp_sub VALUES (8,1,'74881'); +INSERT INTO num_exp_mul VALUES (8,1,'0'); +INSERT INTO num_exp_div VALUES (8,1,'NaN'); +INSERT INTO num_exp_add VALUES (8,2,'-34263611.215397047'); +INSERT INTO num_exp_sub VALUES (8,2,'34413373.215397047'); +INSERT INTO num_exp_mul VALUES (8,2,'-2571300635581.146276407'); +INSERT INTO num_exp_div VALUES (8,2,'-.00218067233500788615'); +INSERT INTO num_exp_add VALUES (8,3,'74885.31'); +INSERT INTO num_exp_sub VALUES (8,3,'74876.69'); +INSERT INTO num_exp_mul VALUES (8,3,'322737.11'); +INSERT INTO num_exp_div VALUES (8,3,'17373.78190255220417633410'); +INSERT INTO num_exp_add VALUES (8,4,'7874342.4119'); +INSERT INTO num_exp_sub VALUES (8,4,'-7724580.4119'); +INSERT INTO num_exp_mul VALUES (8,4,'584031469984.4839'); +INSERT INTO num_exp_div VALUES (8,4,'.00960079113741758956'); +INSERT INTO num_exp_add VALUES (8,5,'91278.038491'); +INSERT INTO num_exp_sub VALUES (8,5,'58483.961509'); +INSERT INTO num_exp_mul VALUES (8,5,'1227826639.244571'); +INSERT INTO num_exp_div VALUES (8,5,'4.56673929509287019456'); +INSERT INTO num_exp_add VALUES (8,6,'168782.57763026'); +INSERT INTO num_exp_sub VALUES (8,6,'-19020.57763026'); +INSERT INTO num_exp_mul VALUES (8,6,'7031444034.53149906'); +INSERT INTO num_exp_div VALUES (8,6,'.79744134113322314424'); +INSERT INTO num_exp_add VALUES (8,7,'-82953604'); +INSERT INTO num_exp_sub VALUES (8,7,'83103366'); +INSERT INTO num_exp_mul VALUES (8,7,'-6217255985285'); +INSERT INTO num_exp_div VALUES (8,7,'-.00090187120721280172'); +INSERT INTO num_exp_add VALUES (8,8,'149762'); +INSERT INTO num_exp_sub VALUES (8,8,'0'); +INSERT INTO num_exp_mul VALUES (8,8,'5607164161'); +INSERT INTO num_exp_div VALUES (8,8,'1.00000000000000000000'); +INSERT INTO num_exp_add VALUES (8,9,'-24851923.045047420'); +INSERT INTO num_exp_sub VALUES (8,9,'25001685.045047420'); +INSERT INTO num_exp_mul VALUES (8,9,'-1866544013697.195857020'); +INSERT INTO num_exp_div VALUES (8,9,'-.00300403532938582735'); +INSERT INTO num_exp_add VALUES (9,0,'-24926804.045047420'); +INSERT INTO num_exp_sub VALUES (9,0,'-24926804.045047420'); +INSERT INTO num_exp_mul VALUES (9,0,'0'); +INSERT INTO num_exp_div VALUES (9,0,'NaN'); +INSERT INTO num_exp_add VALUES (9,1,'-24926804.045047420'); +INSERT INTO num_exp_sub VALUES (9,1,'-24926804.045047420'); +INSERT INTO num_exp_mul VALUES (9,1,'0'); +INSERT INTO num_exp_div VALUES (9,1,'NaN'); +INSERT INTO num_exp_add VALUES (9,2,'-59265296.260444467'); +INSERT INTO num_exp_sub VALUES (9,2,'9411688.170349627'); +INSERT INTO num_exp_mul VALUES (9,2,'855948866655588.453741509242968740'); +INSERT INTO num_exp_div VALUES (9,2,'.72591434384152961526'); +INSERT INTO num_exp_add VALUES (9,3,'-24926799.735047420'); +INSERT INTO num_exp_sub VALUES (9,3,'-24926808.355047420'); +INSERT INTO num_exp_mul VALUES (9,3,'-107434525.43415438020'); +INSERT INTO num_exp_div VALUES (9,3,'-5783481.21694835730858468677'); +INSERT INTO num_exp_add VALUES (9,4,'-17127342.633147420'); +INSERT INTO num_exp_sub VALUES (9,4,'-32726265.456947420'); +INSERT INTO num_exp_mul VALUES (9,4,'-194415646271340.1815956522980'); +INSERT INTO num_exp_div VALUES (9,4,'-3.19596478892958416484'); +INSERT INTO num_exp_add VALUES (9,5,'-24910407.006556420'); +INSERT INTO num_exp_sub VALUES (9,5,'-24943201.083538420'); +INSERT INTO num_exp_mul VALUES (9,5,'-408725765384.257043660243220'); +INSERT INTO num_exp_div VALUES (9,5,'-1520.20159364322004505807'); +INSERT INTO num_exp_add VALUES (9,6,'-24832902.467417160'); +INSERT INTO num_exp_sub VALUES (9,6,'-25020705.622677680'); +INSERT INTO num_exp_mul VALUES (9,6,'-2340666225110.29929521292692920'); +INSERT INTO num_exp_div VALUES (9,6,'-265.45671195426965751280'); +INSERT INTO num_exp_add VALUES (9,7,'-107955289.045047420'); +INSERT INTO num_exp_sub VALUES (9,7,'58101680.954952580'); +INSERT INTO num_exp_mul VALUES (9,7,'2069634775752159.035758700'); +INSERT INTO num_exp_div VALUES (9,7,'.30021990699995814689'); +INSERT INTO num_exp_add VALUES (9,8,'-24851923.045047420'); +INSERT INTO num_exp_sub VALUES (9,8,'-25001685.045047420'); +INSERT INTO num_exp_mul VALUES (9,8,'-1866544013697.195857020'); +INSERT INTO num_exp_div VALUES (9,8,'-332.88556569820675471748'); +INSERT INTO num_exp_add VALUES (9,9,'-49853608.090094840'); +INSERT INTO num_exp_sub VALUES (9,9,'0'); +INSERT INTO num_exp_mul VALUES (9,9,'621345559900192.420120630048656400'); +INSERT INTO num_exp_div VALUES (9,9,'1.00000000000000000000'); +COMMIT TRANSACTION; +BEGIN TRANSACTION; +INSERT INTO num_exp_sqrt VALUES (0,'0'); +INSERT INTO num_exp_sqrt VALUES (1,'0'); +INSERT INTO num_exp_sqrt VALUES (2,'5859.90547836712524903505'); +INSERT INTO num_exp_sqrt VALUES (3,'2.07605394920266944396'); +INSERT INTO num_exp_sqrt VALUES (4,'2792.75158435189147418923'); +INSERT INTO num_exp_sqrt VALUES (5,'128.05092147657509145473'); +INSERT INTO num_exp_sqrt VALUES (6,'306.43364311096782703406'); +INSERT INTO num_exp_sqrt VALUES (7,'9111.99676251039939975230'); +INSERT INTO num_exp_sqrt VALUES (8,'273.64392922189960397542'); +INSERT INTO num_exp_sqrt VALUES (9,'4992.67503899937593364766'); +COMMIT TRANSACTION; +BEGIN TRANSACTION; +INSERT INTO num_exp_ln VALUES (0,'NaN'); +INSERT INTO num_exp_ln VALUES (1,'NaN'); +INSERT INTO num_exp_ln VALUES (2,'17.35177750493897715514'); +INSERT INTO num_exp_ln VALUES (3,'1.46093790411565641971'); +INSERT INTO num_exp_ln VALUES (4,'15.86956523951936572464'); +INSERT INTO num_exp_ln VALUES (5,'9.70485601768871834038'); +INSERT INTO num_exp_ln VALUES (6,'11.45000246622944403127'); +INSERT INTO num_exp_ln VALUES (7,'18.23469429965478772991'); +INSERT INTO num_exp_ln VALUES (8,'11.22365546576315513668'); +INSERT INTO num_exp_ln VALUES (9,'17.03145425013166006962'); +COMMIT TRANSACTION; +BEGIN TRANSACTION; +INSERT INTO num_exp_log10 VALUES (0,'NaN'); +INSERT INTO num_exp_log10 VALUES (1,'NaN'); +INSERT INTO num_exp_log10 VALUES (2,'7.53578122160797276459'); +INSERT INTO num_exp_log10 VALUES (3,'.63447727016073160075'); +INSERT INTO num_exp_log10 VALUES (4,'6.89206461372691743345'); +INSERT INTO num_exp_log10 VALUES (5,'4.21476541614777768626'); +INSERT INTO num_exp_log10 VALUES (6,'4.97267288886207207671'); +INSERT INTO num_exp_log10 VALUES (7,'7.91922711353275546914'); +INSERT INTO num_exp_log10 VALUES (8,'4.87437163556421004138'); +INSERT INTO num_exp_log10 VALUES (9,'7.39666659961986567059'); +COMMIT TRANSACTION; +BEGIN TRANSACTION; +INSERT INTO num_exp_power_10_ln VALUES (0,'NaN'); +INSERT INTO num_exp_power_10_ln VALUES (1,'NaN'); +INSERT INTO num_exp_power_10_ln VALUES (2,'224790267919917955.13261618583642653184'); +INSERT INTO num_exp_power_10_ln VALUES (3,'28.90266599445155957393'); +INSERT INTO num_exp_power_10_ln VALUES (4,'7405685069594999.07733999469386277636'); +INSERT INTO num_exp_power_10_ln VALUES (5,'5068226527.32127265408584640098'); +INSERT INTO num_exp_power_10_ln VALUES (6,'281839893606.99372343357047819067'); +INSERT INTO num_exp_power_10_ln VALUES (7,'1716699575118597095.42330819910640247627'); +INSERT INTO num_exp_power_10_ln VALUES (8,'167361463828.07491320069016125952'); +INSERT INTO num_exp_power_10_ln VALUES (9,'107511333880052007.04141124673540337457'); +COMMIT TRANSACTION; +BEGIN TRANSACTION; +INSERT INTO num_data VALUES (0, '0'); +INSERT INTO num_data VALUES (1, '0'); +INSERT INTO num_data VALUES (2, '-34338492.215397047'); +INSERT INTO num_data VALUES (3, '4.31'); +INSERT INTO num_data VALUES (4, '7799461.4119'); +INSERT INTO num_data VALUES (5, '16397.038491'); +INSERT INTO num_data VALUES (6, '93901.57763026'); +INSERT INTO num_data VALUES (7, '-83028485'); +INSERT INTO num_data VALUES (8, '74881'); +INSERT INTO num_data VALUES (9, '-24926804.045047420'); +COMMIT TRANSACTION; +-- ****************************** +-- * Create indices for faster checks +-- ****************************** +CREATE UNIQUE INDEX num_exp_add_idx ON num_exp_add (id1, id2); +CREATE UNIQUE INDEX num_exp_sub_idx ON num_exp_sub (id1, id2); +CREATE UNIQUE INDEX num_exp_div_idx ON num_exp_div (id1, id2); +CREATE UNIQUE INDEX num_exp_mul_idx ON num_exp_mul (id1, id2); +CREATE UNIQUE INDEX num_exp_sqrt_idx ON num_exp_sqrt (id); +CREATE UNIQUE INDEX num_exp_ln_idx ON num_exp_ln (id); +CREATE UNIQUE INDEX num_exp_log10_idx ON num_exp_log10 (id); +CREATE UNIQUE INDEX num_exp_power_10_ln_idx ON num_exp_power_10_ln (id); +VACUUM ANALYZE num_exp_add; +VACUUM ANALYZE num_exp_sub; +VACUUM ANALYZE num_exp_div; +VACUUM ANALYZE num_exp_mul; +VACUUM ANALYZE num_exp_sqrt; +VACUUM ANALYZE num_exp_ln; +VACUUM ANALYZE num_exp_log10; +VACUUM ANALYZE num_exp_power_10_ln; +-- ****************************** +-- * Now check the behaviour of the NUMERIC type +-- ****************************** +-- ****************************** +-- * Addition check +-- ****************************** +DELETE FROM num_result; +INSERT INTO num_result SELECT t1.id, t2.id, t1.val + t2.val + FROM num_data t1, num_data t2; +SELECT t1.id1, t1.id2, t1.result, t2.expected + FROM num_result t1, num_exp_add t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != t2.expected ORDER BY t1.id1, t1.id2, t2.expected; + id1 | id2 | result | expected +-----+-----+--------+---------- +(0 rows) + +DELETE FROM num_result; +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val + t2.val, 10) + FROM num_data t1, num_data t2; +SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 10) as expected + FROM num_result t1, num_exp_add t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != round(t2.expected, 10) ORDER BY t1.id1, t1.id2; + id1 | id2 | result | expected +-----+-----+--------+---------- +(0 rows) + +-- ****************************** +-- * Subtraction check +-- ****************************** +DELETE FROM num_result; +INSERT INTO num_result SELECT t1.id, t2.id, t1.val - t2.val + FROM num_data t1, num_data t2; +SELECT t1.id1, t1.id2, t1.result, t2.expected + FROM num_result t1, num_exp_sub t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != t2.expected ORDER BY t1.id1, t1.id2, t2.expected; + id1 | id2 | result | expected +-----+-----+--------+---------- +(0 rows) + +DELETE FROM num_result; +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val - t2.val, 40) + FROM num_data t1, num_data t2; +SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 40) + FROM num_result t1, num_exp_sub t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != round(t2.expected, 40); + id1 | id2 | result | round +-----+-----+--------+------- +(0 rows) + +-- ****************************** +-- * Multiply check +-- ****************************** +DELETE FROM num_result; +INSERT INTO num_result SELECT t1.id, t2.id, t1.val * t2.val + FROM num_data t1, num_data t2; +SELECT t1.id1, t1.id2, t1.result, t2.expected + FROM num_result t1, num_exp_mul t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != t2.expected; + id1 | id2 | result | expected +-----+-----+--------+---------- +(0 rows) + +DELETE FROM num_result; +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val * t2.val, 30) + FROM num_data t1, num_data t2; +SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 30) as expected + FROM num_result t1, num_exp_mul t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != round(t2.expected, 30); + id1 | id2 | result | expected +-----+-----+--------+---------- +(0 rows) + +-- ****************************** +-- * Division check +-- ****************************** +DELETE FROM num_result; +INSERT INTO num_result SELECT t1.id, t2.id, t1.val / t2.val + FROM num_data t1, num_data t2 + WHERE t2.val != '0.0'; +SELECT t1.id1, t1.id2, t1.result, t2.expected + FROM num_result t1, num_exp_div t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != t2.expected; + id1 | id2 | result | expected +-----+-----+--------+---------- +(0 rows) + +DELETE FROM num_result; +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val / t2.val, 80) + FROM num_data t1, num_data t2 + WHERE t2.val != '0.0'; +SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 80) as expected + FROM num_result t1, num_exp_div t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != round(t2.expected, 80); + id1 | id2 | result | expected +-----+-----+--------+---------- +(0 rows) + +-- ****************************** +-- * Square root check +-- ****************************** +DELETE FROM num_result; +INSERT INTO num_result SELECT id, 0, SQRT(ABS(val)) + FROM num_data; +SELECT t1.id1, t1.result, t2.expected + FROM num_result t1, num_exp_sqrt t2 + WHERE t1.id1 = t2.id + AND t1.result != t2.expected; + id1 | result | expected +-----+--------+---------- +(0 rows) + +-- ****************************** +-- * Natural logarithm check +-- ****************************** +DELETE FROM num_result; +INSERT INTO num_result SELECT id, 0, LN(ABS(val)) + FROM num_data + WHERE val != '0.0'; +SELECT t1.id1, t1.result, t2.expected + FROM num_result t1, num_exp_ln t2 + WHERE t1.id1 = t2.id + AND t1.result != t2.expected; + id1 | result | expected +-----+--------+---------- +(0 rows) + +-- ****************************** +-- * Logarithm base 10 check +-- ****************************** +DELETE FROM num_result; +INSERT INTO num_result SELECT id, 0, LOG(numeric '10', ABS(val)) + FROM num_data + WHERE val != '0.0'; +SELECT t1.id1, t1.result, t2.expected + FROM num_result t1, num_exp_log10 t2 + WHERE t1.id1 = t2.id + AND t1.result != t2.expected; + id1 | result | expected +-----+--------+---------- +(0 rows) + +-- ****************************** +-- * POWER(10, LN(value)) check +-- ****************************** +DELETE FROM num_result; +INSERT INTO num_result SELECT id, 0, POWER(numeric '10', LN(ABS(round(val,200)))) + FROM num_data + WHERE val != '0.0'; +SELECT t1.id1, t1.result, t2.expected + FROM num_result t1, num_exp_power_10_ln t2 + WHERE t1.id1 = t2.id + AND t1.result != t2.expected; + id1 | result | expected +-----+--------+---------- +(0 rows) + +-- ****************************** +-- * miscellaneous checks for things that have been broken in the past... +-- ****************************** +-- numeric AVG used to fail on some platforms +SELECT AVG(val) FROM num_data; + avg +------------------------ + -13430913.592242320700 +(1 row) + +SELECT STDDEV(val) FROM num_data; + stddev +------------------------------- + 27791203.28758835329805617386 +(1 row) + +SELECT VARIANCE(val) FROM num_data; + variance +-------------------------------------- + 772350980172061.69659105821915863601 +(1 row) + +-- Check for appropriate rounding and overflow +CREATE TABLE fract_only (id int, val numeric(4,4)); +INSERT INTO fract_only VALUES (1, '0.0'); +INSERT INTO fract_only VALUES (2, '0.1'); +INSERT INTO fract_only VALUES (3, '1.0'); -- should fail +ERROR: numeric field overflow +INSERT INTO fract_only VALUES (4, '-0.9999'); +INSERT INTO fract_only VALUES (5, '0.99994'); +INSERT INTO fract_only VALUES (6, '0.99995'); -- should fail +ERROR: numeric field overflow +INSERT INTO fract_only VALUES (7, '0.00001'); +INSERT INTO fract_only VALUES (8, '0.00017'); +SELECT * FROM fract_only ORDER BY id; + id | val +----+--------- + 1 | 0.0000 + 2 | 0.1000 + 4 | -0.9999 + 5 | 0.9999 + 7 | 0.0000 + 8 | 0.0002 +(6 rows) + +DROP TABLE fract_only; +-- Simple check that ceil(), floor(), and round() work correctly +CREATE TABLE ceil_floor_round (a numeric); +INSERT INTO ceil_floor_round VALUES ('-5.5'); +INSERT INTO ceil_floor_round VALUES ('-5.499999'); +INSERT INTO ceil_floor_round VALUES ('9.5'); +INSERT INTO ceil_floor_round VALUES ('9.4999999'); +INSERT INTO ceil_floor_round VALUES ('0.0'); +INSERT INTO ceil_floor_round VALUES ('0.0000001'); +INSERT INTO ceil_floor_round VALUES ('-0.000001'); +SELECT a, ceil(a), ceiling(a), floor(a), round(a) FROM ceil_floor_round ORDER BY a; + a | ceil | ceiling | floor | round +-----------+------+---------+-------+------- + -5.5 | -5 | -5 | -6 | -6 + -5.499999 | -5 | -5 | -6 | -5 + -0.000001 | 0 | 0 | -1 | 0 + 0.0 | 0 | 0 | 0 | 0 + 0.0000001 | 1 | 1 | 0 | 0 + 9.4999999 | 10 | 10 | 9 | 9 + 9.5 | 10 | 10 | 9 | 10 +(7 rows) + +DROP TABLE ceil_floor_round; +-- Testing for width_bucket(). For convenience, we test both the +-- numeric and float8 versions of the function in this file. +-- errors +SELECT width_bucket(5.0, 3.0, 4.0, 0); +ERROR: count must be greater than zero +SELECT width_bucket(5.0, 3.0, 4.0, -5); +ERROR: count must be greater than zero +SELECT width_bucket(3.5, 3.0, 3.0, 888); +ERROR: lower bound cannot equal upper bound +SELECT width_bucket(5.0::float8, 3.0::float8, 4.0::float8, 0); +ERROR: count must be greater than zero +SELECT width_bucket(5.0::float8, 3.0::float8, 4.0::float8, -5); +ERROR: count must be greater than zero +SELECT width_bucket(3.5::float8, 3.0::float8, 3.0::float8, 888); +ERROR: lower bound cannot equal upper bound +SELECT width_bucket('NaN', 3.0, 4.0, 888); +ERROR: operand, lower bound and upper bound cannot be NaN +SELECT width_bucket(0::float8, 'NaN', 4.0::float8, 888); +ERROR: operand, lower bound and upper bound cannot be NaN +-- normal operation +CREATE TABLE width_bucket_test (operand_num numeric, operand_f8 float8); +COPY width_bucket_test (operand_num) FROM stdin; +UPDATE width_bucket_test SET operand_f8 = operand_num::float8; +SELECT + operand_num, + width_bucket(operand_num, 0, 10, 5) AS wb_1, + width_bucket(operand_f8, 0, 10, 5) AS wb_1f, + width_bucket(operand_num, 10, 0, 5) AS wb_2, + width_bucket(operand_f8, 10, 0, 5) AS wb_2f, + width_bucket(operand_num, 2, 8, 4) AS wb_3, + width_bucket(operand_f8, 2, 8, 4) AS wb_3f, + width_bucket(operand_num, 5.0, 5.5, 20) AS wb_4, + width_bucket(operand_f8, 5.0, 5.5, 20) AS wb_4f, + width_bucket(operand_num, -25, 25, 10) AS wb_5, + width_bucket(operand_f8, -25, 25, 10) AS wb_5f + FROM width_bucket_test ORDER BY operand_num; + operand_num | wb_1 | wb_1f | wb_2 | wb_2f | wb_3 | wb_3f | wb_4 | wb_4f | wb_5 | wb_5f +------------------+------+-------+------+-------+------+-------+------+-------+------+------- + -5.2 | 0 | 0 | 6 | 6 | 0 | 0 | 0 | 0 | 4 | 4 + -0.0000000001 | 0 | 0 | 6 | 6 | 0 | 0 | 0 | 0 | 5 | 5 + 0.000000000001 | 1 | 1 | 5 | 5 | 0 | 0 | 0 | 0 | 6 | 6 + 1 | 1 | 1 | 5 | 5 | 0 | 0 | 0 | 0 | 6 | 6 + 1.99999999999999 | 1 | 1 | 5 | 5 | 0 | 0 | 0 | 0 | 6 | 6 + 2 | 2 | 2 | 5 | 5 | 1 | 1 | 0 | 0 | 6 | 6 + 2.00000000000001 | 2 | 2 | 4 | 4 | 1 | 1 | 0 | 0 | 6 | 6 + 3 | 2 | 2 | 4 | 4 | 1 | 1 | 0 | 0 | 6 | 6 + 4 | 3 | 3 | 4 | 4 | 2 | 2 | 0 | 0 | 6 | 6 + 4.5 | 3 | 3 | 3 | 3 | 2 | 2 | 0 | 0 | 6 | 6 + 5 | 3 | 3 | 3 | 3 | 3 | 3 | 1 | 1 | 7 | 7 + 5.5 | 3 | 3 | 3 | 3 | 3 | 3 | 21 | 21 | 7 | 7 + 6 | 4 | 4 | 3 | 3 | 3 | 3 | 21 | 21 | 7 | 7 + 7 | 4 | 4 | 2 | 2 | 4 | 4 | 21 | 21 | 7 | 7 + 8 | 5 | 5 | 2 | 2 | 5 | 5 | 21 | 21 | 7 | 7 + 9 | 5 | 5 | 1 | 1 | 5 | 5 | 21 | 21 | 7 | 7 + 9.99999999999999 | 5 | 5 | 1 | 1 | 5 | 5 | 21 | 21 | 7 | 7 + 10 | 6 | 6 | 1 | 1 | 5 | 5 | 21 | 21 | 8 | 8 + 10.0000000000001 | 6 | 6 | 0 | 0 | 5 | 5 | 21 | 21 | 8 | 8 +(19 rows) + +-- for float8 only, check positive and negative infinity: we require +-- finite bucket bounds, but allow an infinite operand +SELECT width_bucket(0.0::float8, 'Infinity'::float8, 5, 10); -- error +ERROR: lower and upper bounds must be finite +SELECT width_bucket(0.0::float8, 5, '-Infinity'::float8, 20); -- error +ERROR: lower and upper bounds must be finite +SELECT width_bucket('Infinity'::float8, 1, 10, 10), + width_bucket('-Infinity'::float8, 1, 10, 10); + width_bucket | width_bucket +--------------+-------------- + 11 | 0 +(1 row) + +DROP TABLE width_bucket_test; +-- TO_CHAR() +-- +SELECT '' AS to_char_1, to_char(val, '9G999G999G999G999G999') + FROM num_data ORDER BY val; + to_char_1 | to_char +-----------+------------------------ + | -83,028,485 + | -34,338,492 + | -24,926,804 + | 0 + | 0 + | 4 + | 16,397 + | 74,881 + | 93,902 + | 7,799,461 +(10 rows) + +SELECT '' AS to_char_2, to_char(val, '9G999G999G999G999G999D999G999G999G999G999') + FROM num_data ORDER BY val; + to_char_2 | to_char +-----------+-------------------------------------------- + | -83,028,485.000,000,000,000,000 + | -34,338,492.215,397,047,000,000 + | -24,926,804.045,047,420,000,000 + | .000,000,000,000,000 + | .000,000,000,000,000 + | 4.310,000,000,000,000 + | 16,397.038,491,000,000,000 + | 74,881.000,000,000,000,000 + | 93,901.577,630,260,000,000 + | 7,799,461.411,900,000,000,000 +(10 rows) + +SELECT '' AS to_char_3, to_char(val, '9999999999999999.999999999999999PR') + FROM num_data ORDER BY val; + to_char_3 | to_char +-----------+------------------------------------ + | <83028485.000000000000000> + | <34338492.215397047000000> + | <24926804.045047420000000> + | .000000000000000 + | .000000000000000 + | 4.310000000000000 + | 16397.038491000000000 + | 74881.000000000000000 + | 93901.577630260000000 + | 7799461.411900000000000 +(10 rows) + +SELECT '' AS to_char_4, to_char(val, '9999999999999999.999999999999999S') + FROM num_data ORDER BY val; + to_char_4 | to_char +-----------+----------------------------------- + | 83028485.000000000000000- + | 34338492.215397047000000- + | 24926804.045047420000000- + | .000000000000000+ + | .000000000000000+ + | 4.310000000000000+ + | 16397.038491000000000+ + | 74881.000000000000000+ + | 93901.577630260000000+ + | 7799461.411900000000000+ +(10 rows) + +SELECT '' AS to_char_5, to_char(val, 'MI9999999999999999.999999999999999') FROM num_data ORDER BY val; + to_char_5 | to_char +-----------+----------------------------------- + | - 83028485.000000000000000 + | - 34338492.215397047000000 + | - 24926804.045047420000000 + | .000000000000000 + | .000000000000000 + | 4.310000000000000 + | 16397.038491000000000 + | 74881.000000000000000 + | 93901.577630260000000 + | 7799461.411900000000000 +(10 rows) + +SELECT '' AS to_char_6, to_char(val, 'FMS9999999999999999.999999999999999') FROM num_data ORDER BY val; + to_char_6 | to_char +-----------+--------------------- + | -83028485. + | -34338492.215397047 + | -24926804.04504742 + | +0. + | +0. + | +4.31 + | +16397.038491 + | +74881. + | +93901.57763026 + | +7799461.4119 +(10 rows) + +SELECT '' AS to_char_7, to_char(val, 'FM9999999999999999.999999999999999THPR') FROM num_data ORDER BY val; + to_char_7 | to_char +-----------+---------------------- + | <83028485.> + | <34338492.215397047> + | <24926804.04504742> + | 0. + | 0. + | 4.31 + | 16397.038491 + | 74881. + | 93901.57763026 + | 7799461.4119 +(10 rows) + +SELECT '' AS to_char_8, to_char(val, 'SG9999999999999999.999999999999999th') FROM num_data ORDER BY val; + to_char_8 | to_char +-----------+----------------------------------- + | - 83028485.000000000000000 + | - 34338492.215397047000000 + | - 24926804.045047420000000 + | + .000000000000000 + | + .000000000000000 + | + 4.310000000000000 + | + 16397.038491000000000 + | + 74881.000000000000000 + | + 93901.577630260000000 + | + 7799461.411900000000000 +(10 rows) + +SELECT '' AS to_char_9, to_char(val, '0999999999999999.999999999999999') FROM num_data ORDER BY val; + to_char_9 | to_char +-----------+----------------------------------- + | -0000000083028485.000000000000000 + | -0000000034338492.215397047000000 + | -0000000024926804.045047420000000 + | 0000000000000000.000000000000000 + | 0000000000000000.000000000000000 + | 0000000000000004.310000000000000 + | 0000000000016397.038491000000000 + | 0000000000074881.000000000000000 + | 0000000000093901.577630260000000 + | 0000000007799461.411900000000000 +(10 rows) + +SELECT '' AS to_char_10, to_char(val, 'S0999999999999999.999999999999999') FROM num_data ORDER BY val; + to_char_10 | to_char +------------+----------------------------------- + | -0000000083028485.000000000000000 + | -0000000034338492.215397047000000 + | -0000000024926804.045047420000000 + | +0000000000000000.000000000000000 + | +0000000000000000.000000000000000 + | +0000000000000004.310000000000000 + | +0000000000016397.038491000000000 + | +0000000000074881.000000000000000 + | +0000000000093901.577630260000000 + | +0000000007799461.411900000000000 +(10 rows) + +SELECT '' AS to_char_11, to_char(val, 'FM0999999999999999.999999999999999') FROM num_data ORDER BY val; + to_char_11 | to_char +------------+----------------------------- + | -0000000083028485. + | -0000000034338492.215397047 + | -0000000024926804.04504742 + | 0000000000000000. + | 0000000000000000. + | 0000000000000004.31 + | 0000000000016397.038491 + | 0000000000074881. + | 0000000000093901.57763026 + | 0000000007799461.4119 +(10 rows) + +SELECT '' AS to_char_12, to_char(val, 'FM9999999999999999.099999999999999') FROM num_data ORDER BY val; + to_char_12 | to_char +------------+--------------------- + | -83028485.0 + | -34338492.215397047 + | -24926804.04504742 + | .0 + | .0 + | 4.31 + | 16397.038491 + | 74881.0 + | 93901.57763026 + | 7799461.4119 +(10 rows) + +SELECT '' AS to_char_13, to_char(val, 'FM9999999999990999.990999999999999') FROM num_data ORDER BY val; + to_char_13 | to_char +------------+--------------------- + | -83028485.000 + | -34338492.215397047 + | -24926804.04504742 + | 0000.000 + | 0000.000 + | 0004.310 + | 16397.038491 + | 74881.000 + | 93901.57763026 + | 7799461.4119 +(10 rows) + +SELECT '' AS to_char_14, to_char(val, 'FM0999999999999999.999909999999999') FROM num_data ORDER BY val; + to_char_14 | to_char +------------+----------------------------- + | -0000000083028485.00000 + | -0000000034338492.215397047 + | -0000000024926804.04504742 + | 0000000000000000.00000 + | 0000000000000000.00000 + | 0000000000000004.31000 + | 0000000000016397.038491 + | 0000000000074881.00000 + | 0000000000093901.57763026 + | 0000000007799461.41190 +(10 rows) + +SELECT '' AS to_char_15, to_char(val, 'FM9999999990999999.099999999999999') FROM num_data ORDER BY val; + to_char_15 | to_char +------------+--------------------- + | -83028485.0 + | -34338492.215397047 + | -24926804.04504742 + | 0000000.0 + | 0000000.0 + | 0000004.31 + | 0016397.038491 + | 0074881.0 + | 0093901.57763026 + | 7799461.4119 +(10 rows) + +SELECT '' AS to_char_16, to_char(val, 'L9999999999999999.099999999999999') FROM num_data ORDER BY val; + to_char_16 | to_char +------------+------------------------------------ + | $ -83028485.000000000000000 + | -34338492.215397047000000 + | $ -24926804.045047420000000 + | $ .000000000000000 + | $ .000000000000000 + | 4.310000000000000 + | 16397.038491000000000 + | 74881.000000000000000 + | $ 93901.577630260000000 + | $ 7799461.411900000000000 +(10 rows) + +SELECT '' AS to_char_17, to_char(val, 'FM9999999999999999.99999999999999') FROM num_data ORDER BY val; + to_char_17 | to_char +------------+--------------------- + | -83028485. + | -34338492.215397047 + | -24926804.04504742 + | 0. + | 0. + | 4.31 + | 16397.038491 + | 74881. + | 93901.57763026 + | 7799461.4119 +(10 rows) + +SELECT '' AS to_char_18, to_char(val, 'S 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 . 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9') FROM num_data ORDER BY val; + to_char_18 | to_char +------------+----------------------------------------------------------------------- + | -8 3 0 2 8 4 8 5 . 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + | -3 4 3 3 8 4 9 2 . 2 1 5 3 9 7 0 4 7 0 0 0 0 0 0 0 0 + | -2 4 9 2 6 8 0 4 . 0 4 5 0 4 7 4 2 0 0 0 0 0 0 0 0 0 + | +. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + | +. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + | +4 . 3 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + | +1 6 3 9 7 . 0 3 8 4 9 1 0 0 0 0 0 0 0 0 0 0 0 + | +7 4 8 8 1 . 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + | +9 3 9 0 1 . 5 7 7 6 3 0 2 6 0 0 0 0 0 0 0 0 0 + | +7 7 9 9 4 6 1 . 4 1 1 9 0 0 0 0 0 0 0 0 0 0 0 0 0 +(10 rows) + +SELECT '' AS to_char_19, to_char(val, 'FMS 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 . 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9') FROM num_data ORDER BY val; + to_char_19 | to_char +------------+------------------------------------------------------- + | -8 3 0 2 8 4 8 5 . + | -3 4 3 3 8 4 9 2 . 2 1 5 3 9 7 0 4 7 + | -2 4 9 2 6 8 0 4 . 0 4 5 0 4 7 4 2 + | +0 . + | +0 . + | +4 . 3 1 + | +1 6 3 9 7 . 0 3 8 4 9 1 + | +7 4 8 8 1 . + | +9 3 9 0 1 . 5 7 7 6 3 0 2 6 + | +7 7 9 9 4 6 1 . 4 1 1 9 +(10 rows) + +SELECT '' AS to_char_20, to_char(val, E'99999 "text" 9999 "9999" 999 "\\"text between quote marks\\"" 9999') FROM num_data ORDER BY val; + to_char_20 | to_char +------------+----------------------------------------------------------- + | text -8 9999 302 "text between quote marks" 8485 + | text -3 9999 433 "text between quote marks" 8492 + | text -2 9999 492 "text between quote marks" 6804 + | text 9999 "text between quote marks" 0 + | text 9999 "text between quote marks" 0 + | text 9999 "text between quote marks" 4 + | text 9999 1 "text between quote marks" 6397 + | text 9999 7 "text between quote marks" 4881 + | text 9999 9 "text between quote marks" 3902 + | text 9999 779 "text between quote marks" 9461 +(10 rows) + +SELECT '' AS to_char_21, to_char(val, '999999SG9999999999') FROM num_data ORDER BY val; + to_char_21 | to_char +------------+------------------- + | - 83028485 + | - 34338492 + | - 24926804 + | + 0 + | + 0 + | + 4 + | + 16397 + | + 74881 + | + 93902 + | + 7799461 +(10 rows) + +SELECT '' AS to_char_22, to_char(val, 'FM9999999999999999.999999999999999') FROM num_data ORDER BY val; + to_char_22 | to_char +------------+--------------------- + | -83028485. + | -34338492.215397047 + | -24926804.04504742 + | 0. + | 0. + | 4.31 + | 16397.038491 + | 74881. + | 93901.57763026 + | 7799461.4119 +(10 rows) + +-- TO_NUMBER() +-- +SELECT '' AS to_number_1, to_number('-34,338,492', '99G999G999'); + to_number_1 | to_number +-------------+----------- + | -34338492 +(1 row) + +SELECT '' AS to_number_2, to_number('-34,338,492.654,878', '99G999G999D999G999'); + to_number_2 | to_number +-------------+------------------ + | -34338492.654878 +(1 row) + +SELECT '' AS to_number_3, to_number('<564646.654564>', '999999.999999PR'); + to_number_3 | to_number +-------------+---------------- + | -564646.654564 +(1 row) + +SELECT '' AS to_number_4, to_number('0.00001-', '9.999999S'); + to_number_4 | to_number +-------------+----------- + | -0.00001 +(1 row) + +SELECT '' AS to_number_5, to_number('5.01-', 'FM9.999999S'); + to_number_5 | to_number +-------------+----------- + | -5.01 +(1 row) + +SELECT '' AS to_number_5, to_number('5.01-', 'FM9.999999MI'); + to_number_5 | to_number +-------------+----------- + | -5.01 +(1 row) + +SELECT '' AS to_number_7, to_number('5 4 4 4 4 8 . 7 8', '9 9 9 9 9 9 . 9 9'); + to_number_7 | to_number +-------------+----------- + | 544448.78 +(1 row) + +SELECT '' AS to_number_8, to_number('.01', 'FM9.99'); + to_number_8 | to_number +-------------+----------- + | 0.01 +(1 row) + +SELECT '' AS to_number_9, to_number('.0', '99999999.99999999'); + to_number_9 | to_number +-------------+----------- + | 0.0 +(1 row) + +SELECT '' AS to_number_10, to_number('0', '99.99'); + to_number_10 | to_number +--------------+----------- + | 0 +(1 row) + +SELECT '' AS to_number_11, to_number('.-01', 'S99.99'); + to_number_11 | to_number +--------------+----------- + | -0.01 +(1 row) + +SELECT '' AS to_number_12, to_number('.01-', '99.99S'); + to_number_12 | to_number +--------------+----------- + | -0.01 +(1 row) + +SELECT '' AS to_number_13, to_number(' . 0 1-', ' 9 9 . 9 9 S'); + to_number_13 | to_number +--------------+----------- + | -0.01 +(1 row) + +-- +-- Input syntax +-- +CREATE TABLE num_input_test (n1 numeric); +-- good inputs +INSERT INTO num_input_test(n1) VALUES (' 123'); +INSERT INTO num_input_test(n1) VALUES (' 3245874 '); +INSERT INTO num_input_test(n1) VALUES (' -93853'); +INSERT INTO num_input_test(n1) VALUES ('555.50'); +INSERT INTO num_input_test(n1) VALUES ('-555.50'); +INSERT INTO num_input_test(n1) VALUES ('NaN '); +INSERT INTO num_input_test(n1) VALUES (' nan'); +-- bad inputs +INSERT INTO num_input_test(n1) VALUES (' '); +ERROR: invalid input syntax for type numeric: " " +LINE 1: INSERT INTO num_input_test(n1) VALUES (' '); + ^ +INSERT INTO num_input_test(n1) VALUES (' 1234 %'); +ERROR: invalid input syntax for type numeric: " 1234 %" +LINE 1: INSERT INTO num_input_test(n1) VALUES (' 1234 %'); + ^ +INSERT INTO num_input_test(n1) VALUES ('xyz'); +ERROR: invalid input syntax for type numeric: "xyz" +LINE 1: INSERT INTO num_input_test(n1) VALUES ('xyz'); + ^ +INSERT INTO num_input_test(n1) VALUES ('- 1234'); +ERROR: invalid input syntax for type numeric: "- 1234" +LINE 1: INSERT INTO num_input_test(n1) VALUES ('- 1234'); + ^ +INSERT INTO num_input_test(n1) VALUES ('5 . 0'); +ERROR: invalid input syntax for type numeric: "5 . 0" +LINE 1: INSERT INTO num_input_test(n1) VALUES ('5 . 0'); + ^ +INSERT INTO num_input_test(n1) VALUES ('5. 0 '); +ERROR: invalid input syntax for type numeric: "5. 0 " +LINE 1: INSERT INTO num_input_test(n1) VALUES ('5. 0 '); + ^ +INSERT INTO num_input_test(n1) VALUES (''); +ERROR: invalid input syntax for type numeric: "" +LINE 1: INSERT INTO num_input_test(n1) VALUES (''); + ^ +INSERT INTO num_input_test(n1) VALUES (' N aN '); +ERROR: invalid input syntax for type numeric: " N aN " +LINE 1: INSERT INTO num_input_test(n1) VALUES (' N aN '); + ^ +SELECT * FROM num_input_test ORDER BY n1; + n1 +--------- + -93853 + -555.50 + 123 + 555.50 + 3245874 + NaN + NaN +(7 rows) + +-- +-- Test some corner cases for division +-- +select 999999999999999999999::numeric/1000000000000000000000; + ?column? +------------------------ + 1.00000000000000000000 +(1 row) + +select div(999999999999999999999::numeric,1000000000000000000000); + div +----- + 0 +(1 row) + +select mod(999999999999999999999::numeric,1000000000000000000000); + mod +----------------------- + 999999999999999999999 +(1 row) + +select div(-9999999999999999999999::numeric,1000000000000000000000); + div +----- + -9 +(1 row) + +select mod(-9999999999999999999999::numeric,1000000000000000000000); + mod +------------------------ + -999999999999999999999 +(1 row) + +select div(-9999999999999999999999::numeric,1000000000000000000000)*1000000000000000000000 + mod(-9999999999999999999999::numeric,1000000000000000000000); + ?column? +------------------------- + -9999999999999999999999 +(1 row) + +select mod (70.0,70) ; + mod +----- + 0.0 +(1 row) + +select div (70.0,70) ; + div +----- + 1 +(1 row) + +select 70.0 / 70 ; + ?column? +------------------------ + 1.00000000000000000000 +(1 row) + +select 12345678901234567890 % 123; + ?column? +---------- + 78 +(1 row) + +select 12345678901234567890 / 123; + ?column? +-------------------- + 100371373180768845 +(1 row) + +select div(12345678901234567890, 123); + div +-------------------- + 100371373180768844 +(1 row) + +select div(12345678901234567890, 123) * 123 + 12345678901234567890 % 123; + ?column? +---------------------- + 12345678901234567... [truncated message content] |
From: Abbas B. <ga...@us...> - 2011-03-17 16:15:20
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 0115aacecb33438da33b51e7761498de6a854ba3 (commit) from e62b497522fbf7b3ac361b3aef0e8ca23cdda675 (commit) - Log ----------------------------------------------------------------- commit 0115aacecb33438da33b51e7761498de6a854ba3 Author: Abbas <abb...@en...> Date: Thu Mar 17 21:13:35 2011 +0500 Expected output changed to fix regression failure diff --git a/src/test/regress/expected/float8_1.out b/src/test/regress/expected/float8_1.out index 1f79f66..65fe187 100644 --- a/src/test/regress/expected/float8_1.out +++ b/src/test/regress/expected/float8_1.out @@ -381,8 +381,7 @@ SELECT '' AS five, * FROM FLOAT8_TBL ORDER BY f1; UPDATE FLOAT8_TBL SET f1 = FLOAT8_TBL.f1 * '-1' WHERE FLOAT8_TBL.f1 > '0.0'; - -SELECT '' AS bad, f.f1 * '1e200' from FLOAT8_TBL f ORDER BY f1; +SELECT '' AS bad, f.f1 ^ '1e200' from FLOAT8_TBL f ORDER BY f1; ERROR: value out of range: overflow SELECT '' AS bad, f.f1 ^ '1e200' from FLOAT8_TBL f ORDER BY f1; ERROR: value out of range: overflow ----------------------------------------------------------------------- Summary of changes: src/test/regress/expected/float8_1.out | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) hooks/post-receive -- Postgres-XC |
From: Abbas B. <ga...@us...> - 2011-03-17 16:09:43
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via e62b497522fbf7b3ac361b3aef0e8ca23cdda675 (commit) from bce5904c777b305c7706146077c2a692e7dad52e (commit) - Log ----------------------------------------------------------------- commit e62b497522fbf7b3ac361b3aef0e8ca23cdda675 Author: Abbas <abb...@en...> Date: Thu Mar 17 21:07:24 2011 +0500 Add alternate expected output files to take care of regression failures diff --git a/src/test/regress/expected/int8_1.out b/src/test/regress/expected/int8_1.out new file mode 100644 index 0000000..ce06501 --- /dev/null +++ b/src/test/regress/expected/int8_1.out @@ -0,0 +1,804 @@ +-- +-- INT8 +-- Test int8 64-bit integers. +-- +CREATE TABLE INT8_TBL(q1 int8, q2 int8); +INSERT INTO INT8_TBL VALUES(' 123 ',' 456'); +INSERT INTO INT8_TBL VALUES('123 ','4567890123456789'); +INSERT INTO INT8_TBL VALUES('4567890123456789','123'); +INSERT INTO INT8_TBL VALUES(+4567890123456789,'4567890123456789'); +INSERT INTO INT8_TBL VALUES('+4567890123456789','-4567890123456789'); +-- bad inputs +INSERT INTO INT8_TBL(q1) VALUES (' '); +ERROR: invalid input syntax for integer: " " +LINE 1: INSERT INTO INT8_TBL(q1) VALUES (' '); + ^ +INSERT INTO INT8_TBL(q1) VALUES ('xxx'); +ERROR: invalid input syntax for integer: "xxx" +LINE 1: INSERT INTO INT8_TBL(q1) VALUES ('xxx'); + ^ +INSERT INTO INT8_TBL(q1) VALUES ('3908203590239580293850293850329485'); +ERROR: value "3908203590239580293850293850329485" is out of range for type bigint +LINE 1: INSERT INTO INT8_TBL(q1) VALUES ('39082035902395802938502938... + ^ +INSERT INTO INT8_TBL(q1) VALUES ('-1204982019841029840928340329840934'); +ERROR: value "-1204982019841029840928340329840934" is out of range for type bigint +LINE 1: INSERT INTO INT8_TBL(q1) VALUES ('-1204982019841029840928340... + ^ +INSERT INTO INT8_TBL(q1) VALUES ('- 123'); +ERROR: invalid input syntax for integer: "- 123" +LINE 1: INSERT INTO INT8_TBL(q1) VALUES ('- 123'); + ^ +INSERT INTO INT8_TBL(q1) VALUES (' 345 5'); +ERROR: invalid input syntax for integer: " 345 5" +LINE 1: INSERT INTO INT8_TBL(q1) VALUES (' 345 5'); + ^ +INSERT INTO INT8_TBL(q1) VALUES (''); +ERROR: invalid input syntax for integer: "" +LINE 1: INSERT INTO INT8_TBL(q1) VALUES (''); + ^ +SELECT * FROM INT8_TBL ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 123 | 456 + 123 | 4567890123456789 + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 + 4567890123456789 | 4567890123456789 +(5 rows) + +-- int8/int8 cmp +SELECT * FROM INT8_TBL WHERE q2 = 4567890123456789 ORDER BY q1,q2; + q1 | q2 +------------------+------------------ + 123 | 4567890123456789 + 4567890123456789 | 4567890123456789 +(2 rows) + +SELECT * FROM INT8_TBL WHERE q2 <> 4567890123456789 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 123 | 456 + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 +(3 rows) + +SELECT * FROM INT8_TBL WHERE q2 < 4567890123456789 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 123 | 456 + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 +(3 rows) + +SELECT * FROM INT8_TBL WHERE q2 > 4567890123456789 ORDER BY q1,q2; + q1 | q2 +----+---- +(0 rows) + +SELECT * FROM INT8_TBL WHERE q2 <= 4567890123456789 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 123 | 456 + 123 | 4567890123456789 + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 + 4567890123456789 | 4567890123456789 +(5 rows) + +SELECT * FROM INT8_TBL WHERE q2 >= 4567890123456789 ORDER BY q1,q2; + q1 | q2 +------------------+------------------ + 123 | 4567890123456789 + 4567890123456789 | 4567890123456789 +(2 rows) + +-- int8/int4 cmp +SELECT * FROM INT8_TBL WHERE q2 = 456 ORDER BY q1,q2; + q1 | q2 +-----+----- + 123 | 456 +(1 row) + +SELECT * FROM INT8_TBL WHERE q2 <> 456 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 123 | 4567890123456789 + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 + 4567890123456789 | 4567890123456789 +(4 rows) + +SELECT * FROM INT8_TBL WHERE q2 < 456 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 +(2 rows) + +SELECT * FROM INT8_TBL WHERE q2 > 456 ORDER BY q1,q2; + q1 | q2 +------------------+------------------ + 123 | 4567890123456789 + 4567890123456789 | 4567890123456789 +(2 rows) + +SELECT * FROM INT8_TBL WHERE q2 <= 456 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 123 | 456 + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 +(3 rows) + +SELECT * FROM INT8_TBL WHERE q2 >= 456 ORDER BY q1,q2; + q1 | q2 +------------------+------------------ + 123 | 456 + 123 | 4567890123456789 + 4567890123456789 | 4567890123456789 +(3 rows) + +-- int4/int8 cmp +SELECT * FROM INT8_TBL WHERE 123 = q1 ORDER BY q1,q2; + q1 | q2 +-----+------------------ + 123 | 456 + 123 | 4567890123456789 +(2 rows) + +SELECT * FROM INT8_TBL WHERE 123 <> q1 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 + 4567890123456789 | 4567890123456789 +(3 rows) + +SELECT * FROM INT8_TBL WHERE 123 < q1 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 + 4567890123456789 | 4567890123456789 +(3 rows) + +SELECT * FROM INT8_TBL WHERE 123 > q1 ORDER BY q1,q2; + q1 | q2 +----+---- +(0 rows) + +SELECT * FROM INT8_TBL WHERE 123 <= q1 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 123 | 456 + 123 | 4567890123456789 + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 + 4567890123456789 | 4567890123456789 +(5 rows) + +SELECT * FROM INT8_TBL WHERE 123 >= q1 ORDER BY q1,q2; + q1 | q2 +-----+------------------ + 123 | 456 + 123 | 4567890123456789 +(2 rows) + +-- int8/int2 cmp +SELECT * FROM INT8_TBL WHERE q2 = '456'::int2 ORDER BY q1,q2; + q1 | q2 +-----+----- + 123 | 456 +(1 row) + +SELECT * FROM INT8_TBL WHERE q2 <> '456'::int2 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 123 | 4567890123456789 + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 + 4567890123456789 | 4567890123456789 +(4 rows) + +SELECT * FROM INT8_TBL WHERE q2 < '456'::int2 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 +(2 rows) + +SELECT * FROM INT8_TBL WHERE q2 > '456'::int2 ORDER BY q1,q2; + q1 | q2 +------------------+------------------ + 123 | 4567890123456789 + 4567890123456789 | 4567890123456789 +(2 rows) + +SELECT * FROM INT8_TBL WHERE q2 <= '456'::int2 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 123 | 456 + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 +(3 rows) + +SELECT * FROM INT8_TBL WHERE q2 >= '456'::int2 ORDER BY q1,q2; + q1 | q2 +------------------+------------------ + 123 | 456 + 123 | 4567890123456789 + 4567890123456789 | 4567890123456789 +(3 rows) + +-- int2/int8 cmp +SELECT * FROM INT8_TBL WHERE '123'::int2 = q1 ORDER BY q1,q2; + q1 | q2 +-----+------------------ + 123 | 456 + 123 | 4567890123456789 +(2 rows) + +SELECT * FROM INT8_TBL WHERE '123'::int2 <> q1 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 + 4567890123456789 | 4567890123456789 +(3 rows) + +SELECT * FROM INT8_TBL WHERE '123'::int2 < q1 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 + 4567890123456789 | 4567890123456789 +(3 rows) + +SELECT * FROM INT8_TBL WHERE '123'::int2 > q1 ORDER BY q1,q2; + q1 | q2 +----+---- +(0 rows) + +SELECT * FROM INT8_TBL WHERE '123'::int2 <= q1 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 123 | 456 + 123 | 4567890123456789 + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 + 4567890123456789 | 4567890123456789 +(5 rows) + +SELECT * FROM INT8_TBL WHERE '123'::int2 >= q1 ORDER BY q1,q2; + q1 | q2 +-----+------------------ + 123 | 456 + 123 | 4567890123456789 +(2 rows) + +SELECT '' AS five, q1 AS plus, -q1 AS minus FROM INT8_TBL ORDER BY q1; + five | plus | minus +------+------------------+------------------- + | 123 | -123 + | 123 | -123 + | 4567890123456789 | -4567890123456789 + | 4567890123456789 | -4567890123456789 + | 4567890123456789 | -4567890123456789 +(5 rows) + +SELECT '' AS five, q1, q2, q1 + q2 AS plus FROM INT8_TBL ORDER BY q1,q2; + five | q1 | q2 | plus +------+------------------+-------------------+------------------ + | 123 | 456 | 579 + | 123 | 4567890123456789 | 4567890123456912 + | 4567890123456789 | -4567890123456789 | 0 + | 4567890123456789 | 123 | 4567890123456912 + | 4567890123456789 | 4567890123456789 | 9135780246913578 +(5 rows) + +SELECT '' AS five, q1, q2, q1 - q2 AS minus FROM INT8_TBL ORDER BY q1,q2; + five | q1 | q2 | minus +------+------------------+-------------------+------------------- + | 123 | 456 | -333 + | 123 | 4567890123456789 | -4567890123456666 + | 4567890123456789 | -4567890123456789 | 9135780246913578 + | 4567890123456789 | 123 | 4567890123456666 + | 4567890123456789 | 4567890123456789 | 0 +(5 rows) + +SELECT '' AS three, q1, q2, q1 * q2 AS multiply FROM INT8_TBL ORDER BY q1,q2; +ERROR: bigint out of range +SELECT '' AS three, q1, q2, q1 * q2 AS multiply FROM INT8_TBL + WHERE q1 < 1000 or (q2 > 0 and q2 < 1000) ORDER BY q1,q2; + three | q1 | q2 | multiply +-------+------------------+------------------+-------------------- + | 123 | 456 | 56088 + | 123 | 4567890123456789 | 561850485185185047 + | 4567890123456789 | 123 | 561850485185185047 +(3 rows) + +SELECT '' AS five, q1, q2, q1 / q2 AS divide, q1 % q2 AS mod FROM INT8_TBL ORDER BY q1,q2; + five | q1 | q2 | divide | mod +------+------------------+-------------------+----------------+----- + | 123 | 456 | 0 | 123 + | 123 | 4567890123456789 | 0 | 123 + | 4567890123456789 | -4567890123456789 | -1 | 0 + | 4567890123456789 | 123 | 37137318076884 | 57 + | 4567890123456789 | 4567890123456789 | 1 | 0 +(5 rows) + +SELECT '' AS five, q1, float8(q1) FROM INT8_TBL ORDER BY q1; + five | q1 | float8 +------+------------------+---------------------- + | 123 | 123 + | 123 | 123 + | 4567890123456789 | 4.56789012345679e+15 + | 4567890123456789 | 4.56789012345679e+15 + | 4567890123456789 | 4.56789012345679e+15 +(5 rows) + +SELECT '' AS five, q2, float8(q2) FROM INT8_TBL ORDER BY q2; + five | q2 | float8 +------+-------------------+----------------------- + | -4567890123456789 | -4.56789012345679e+15 + | 123 | 123 + | 456 | 456 + | 4567890123456789 | 4.56789012345679e+15 + | 4567890123456789 | 4.56789012345679e+15 +(5 rows) + +SELECT 37 + q1 AS plus4 FROM INT8_TBL ORDER BY q1; + plus4 +------------------ + 160 + 160 + 4567890123456826 + 4567890123456826 + 4567890123456826 +(5 rows) + +SELECT 37 - q1 AS minus4 FROM INT8_TBL ORDER BY q1; + minus4 +------------------- + -86 + -86 + -4567890123456752 + -4567890123456752 + -4567890123456752 +(5 rows) + +SELECT '' AS five, 2 * q1 AS "twice int4" FROM INT8_TBL ORDER BY q1; + five | twice int4 +------+------------------ + | 246 + | 246 + | 9135780246913578 + | 9135780246913578 + | 9135780246913578 +(5 rows) + +SELECT '' AS five, q1 * 2 AS "twice int4" FROM INT8_TBL ORDER BY q1; + five | twice int4 +------+------------------ + | 246 + | 246 + | 9135780246913578 + | 9135780246913578 + | 9135780246913578 +(5 rows) + +-- int8 op int4 +SELECT q1 + 42::int4 AS "8plus4", q1 - 42::int4 AS "8minus4", q1 * 42::int4 AS "8mul4", q1 / 42::int4 AS "8div4" FROM INT8_TBL ORDER BY q1; + 8plus4 | 8minus4 | 8mul4 | 8div4 +------------------+------------------+--------------------+----------------- + 165 | 81 | 5166 | 2 + 165 | 81 | 5166 | 2 + 4567890123456831 | 4567890123456747 | 191851385185185138 | 108759288653733 + 4567890123456831 | 4567890123456747 | 191851385185185138 | 108759288653733 + 4567890123456831 | 4567890123456747 | 191851385185185138 | 108759288653733 +(5 rows) + +-- int4 op int8 +SELECT 246::int4 + q1 AS "4plus8", 246::int4 - q1 AS "4minus8", 246::int4 * q1 AS "4mul8", 246::int4 / q1 AS "4div8" FROM INT8_TBL ORDER BY q1; + 4plus8 | 4minus8 | 4mul8 | 4div8 +------------------+-------------------+---------------------+------- + 369 | 123 | 30258 | 2 + 369 | 123 | 30258 | 2 + 4567890123457035 | -4567890123456543 | 1123700970370370094 | 0 + 4567890123457035 | -4567890123456543 | 1123700970370370094 | 0 + 4567890123457035 | -4567890123456543 | 1123700970370370094 | 0 +(5 rows) + +-- int8 op int2 +SELECT q1 + 42::int2 AS "8plus2", q1 - 42::int2 AS "8minus2", q1 * 42::int2 AS "8mul2", q1 / 42::int2 AS "8div2" FROM INT8_TBL ORDER BY q1; + 8plus2 | 8minus2 | 8mul2 | 8div2 +------------------+------------------+--------------------+----------------- + 165 | 81 | 5166 | 2 + 165 | 81 | 5166 | 2 + 4567890123456831 | 4567890123456747 | 191851385185185138 | 108759288653733 + 4567890123456831 | 4567890123456747 | 191851385185185138 | 108759288653733 + 4567890123456831 | 4567890123456747 | 191851385185185138 | 108759288653733 +(5 rows) + +-- int2 op int8 +SELECT 246::int2 + q1 AS "2plus8", 246::int2 - q1 AS "2minus8", 246::int2 * q1 AS "2mul8", 246::int2 / q1 AS "2div8" FROM INT8_TBL ORDER BY q1; + 2plus8 | 2minus8 | 2mul8 | 2div8 +------------------+-------------------+---------------------+------- + 369 | 123 | 30258 | 2 + 369 | 123 | 30258 | 2 + 4567890123457035 | -4567890123456543 | 1123700970370370094 | 0 + 4567890123457035 | -4567890123456543 | 1123700970370370094 | 0 + 4567890123457035 | -4567890123456543 | 1123700970370370094 | 0 +(5 rows) + +SELECT q2, abs(q2) FROM INT8_TBL ORDER BY q2; + q2 | abs +-------------------+------------------ + -4567890123456789 | 4567890123456789 + 123 | 123 + 456 | 456 + 4567890123456789 | 4567890123456789 + 4567890123456789 | 4567890123456789 +(5 rows) + +SELECT min(q1), min(q2) FROM INT8_TBL; + min | min +-----+------------------- + 123 | -4567890123456789 +(1 row) + +SELECT max(q1), max(q2) FROM INT8_TBL; + max | max +------------------+------------------ + 4567890123456789 | 4567890123456789 +(1 row) + +-- TO_CHAR() +-- +SELECT '' AS to_char_1, to_char(q1, '9G999G999G999G999G999'), to_char(q2, '9,999,999,999,999,999') + FROM INT8_TBL ORDER BY q1,q2; + to_char_1 | to_char | to_char +-----------+------------------------+------------------------ + | 123 | 456 + | 123 | 4,567,890,123,456,789 + | 4,567,890,123,456,789 | -4,567,890,123,456,789 + | 4,567,890,123,456,789 | 123 + | 4,567,890,123,456,789 | 4,567,890,123,456,789 +(5 rows) + +SELECT '' AS to_char_2, to_char(q1, '9G999G999G999G999G999D999G999'), to_char(q2, '9,999,999,999,999,999.999,999') + FROM INT8_TBL ORDER BY q1,q2; + to_char_2 | to_char | to_char +-----------+--------------------------------+-------------------------------- + | 123.000,000 | 456.000,000 + | 123.000,000 | 4,567,890,123,456,789.000,000 + | 4,567,890,123,456,789.000,000 | -4,567,890,123,456,789.000,000 + | 4,567,890,123,456,789.000,000 | 123.000,000 + | 4,567,890,123,456,789.000,000 | 4,567,890,123,456,789.000,000 +(5 rows) + +SELECT '' AS to_char_3, to_char( (q1 * -1), '9999999999999999PR'), to_char( (q2 * -1), '9999999999999999.999PR') + FROM INT8_TBL ORDER BY q1,q2; + to_char_3 | to_char | to_char +-----------+--------------------+------------------------ + | <123> | <456.000> + | <123> | <4567890123456789.000> + | <4567890123456789> | 4567890123456789.000 + | <4567890123456789> | <123.000> + | <4567890123456789> | <4567890123456789.000> +(5 rows) + +SELECT '' AS to_char_4, to_char( (q1 * -1), '9999999999999999S'), to_char( (q2 * -1), 'S9999999999999999') + FROM INT8_TBL ORDER BY q1,q2; + to_char_4 | to_char | to_char +-----------+-------------------+------------------- + | 123- | -456 + | 123- | -4567890123456789 + | 4567890123456789- | +4567890123456789 + | 4567890123456789- | -123 + | 4567890123456789- | -4567890123456789 +(5 rows) + +SELECT '' AS to_char_5, to_char(q2, 'MI9999999999999999') FROM INT8_TBL ORDER BY q2; + to_char_5 | to_char +-----------+------------------- + | -4567890123456789 + | 123 + | 456 + | 4567890123456789 + | 4567890123456789 +(5 rows) + +SELECT '' AS to_char_6, to_char(q2, 'FMS9999999999999999') FROM INT8_TBL ORDER BY q2; + to_char_6 | to_char +-----------+------------------- + | -4567890123456789 + | +123 + | +456 + | +4567890123456789 + | +4567890123456789 +(5 rows) + +SELECT '' AS to_char_7, to_char(q2, 'FM9999999999999999THPR') FROM INT8_TBL ORDER BY q2; + to_char_7 | to_char +-----------+-------------------- + | <4567890123456789> + | 123RD + | 456TH + | 4567890123456789TH + | 4567890123456789TH +(5 rows) + +SELECT '' AS to_char_8, to_char(q2, 'SG9999999999999999th') FROM INT8_TBL ORDER BY q2; + to_char_8 | to_char +-----------+--------------------- + | -4567890123456789 + | + 123rd + | + 456th + | +4567890123456789th + | +4567890123456789th +(5 rows) + +SELECT '' AS to_char_9, to_char(q2, '0999999999999999') FROM INT8_TBL ORDER BY q2; + to_char_9 | to_char +-----------+------------------- + | -4567890123456789 + | 0000000000000123 + | 0000000000000456 + | 4567890123456789 + | 4567890123456789 +(5 rows) + +SELECT '' AS to_char_10, to_char(q2, 'S0999999999999999') FROM INT8_TBL ORDER BY q2; + to_char_10 | to_char +------------+------------------- + | -4567890123456789 + | +0000000000000123 + | +0000000000000456 + | +4567890123456789 + | +4567890123456789 +(5 rows) + +SELECT '' AS to_char_11, to_char(q2, 'FM0999999999999999') FROM INT8_TBL ORDER BY q2; + to_char_11 | to_char +------------+------------------- + | -4567890123456789 + | 0000000000000123 + | 0000000000000456 + | 4567890123456789 + | 4567890123456789 +(5 rows) + +SELECT '' AS to_char_12, to_char(q2, 'FM9999999999999999.000') FROM INT8_TBL ORDER BY q2; + to_char_12 | to_char +------------+----------------------- + | -4567890123456789.000 + | 123.000 + | 456.000 + | 4567890123456789.000 + | 4567890123456789.000 +(5 rows) + +SELECT '' AS to_char_13, to_char(q2, 'L9999999999999999.000') FROM INT8_TBL ORDER BY q2; + to_char_13 | to_char +------------+------------------------ + | -4567890123456789.000 + | 123.000 + | 456.000 + | $ 4567890123456789.000 + | $ 4567890123456789.000 +(5 rows) + +SELECT '' AS to_char_14, to_char(q2, 'FM9999999999999999.999') FROM INT8_TBL ORDER BY q2; + to_char_14 | to_char +------------+-------------------- + | -4567890123456789. + | 123. + | 456. + | 4567890123456789. + | 4567890123456789. +(5 rows) + +SELECT '' AS to_char_15, to_char(q2, 'S 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 . 9 9 9') FROM INT8_TBL ORDER BY q2; + to_char_15 | to_char +------------+------------------------------------------- + | -4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 . 0 0 0 + | +1 2 3 . 0 0 0 + | +4 5 6 . 0 0 0 + | +4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 . 0 0 0 + | +4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 . 0 0 0 +(5 rows) + +SELECT '' AS to_char_16, to_char(q2, E'99999 "text" 9999 "9999" 999 "\\"text between quote marks\\"" 9999') FROM INT8_TBL ORDER BY q2; + to_char_16 | to_char +------------+----------------------------------------------------------- + | -45678 text 9012 9999 345 "text between quote marks" 6789 + | text 9999 "text between quote marks" 123 + | text 9999 "text between quote marks" 456 + | 45678 text 9012 9999 345 "text between quote marks" 6789 + | 45678 text 9012 9999 345 "text between quote marks" 6789 +(5 rows) + +SELECT '' AS to_char_17, to_char(q2, '999999SG9999999999') FROM INT8_TBL ORDER BY q2; + to_char_17 | to_char +------------+------------------- + | 456789-0123456789 + | + 123 + | + 456 + | 456789+0123456789 + | 456789+0123456789 +(5 rows) + +-- check min/max values and overflow behavior +select '-9223372036854775808'::int8; + int8 +---------------------- + -9223372036854775808 +(1 row) + +select '-9223372036854775809'::int8; +ERROR: value "-9223372036854775809" is out of range for type bigint +LINE 1: select '-9223372036854775809'::int8; + ^ +select '9223372036854775807'::int8; + int8 +--------------------- + 9223372036854775807 +(1 row) + +select '9223372036854775808'::int8; +ERROR: value "9223372036854775808" is out of range for type bigint +LINE 1: select '9223372036854775808'::int8; + ^ +select -('-9223372036854775807'::int8); + ?column? +--------------------- + 9223372036854775807 +(1 row) + +select -('-9223372036854775808'::int8); +ERROR: bigint out of range +select '9223372036854775800'::int8 + '9223372036854775800'::int8; +ERROR: bigint out of range +select '-9223372036854775800'::int8 + '-9223372036854775800'::int8; +ERROR: bigint out of range +select '9223372036854775800'::int8 - '-9223372036854775800'::int8; +ERROR: bigint out of range +select '-9223372036854775800'::int8 - '9223372036854775800'::int8; +ERROR: bigint out of range +select '9223372036854775800'::int8 * '9223372036854775800'::int8; +ERROR: bigint out of range +select '9223372036854775800'::int8 / '0'::int8; +ERROR: division by zero +select '9223372036854775800'::int8 % '0'::int8; +ERROR: division by zero +select abs('-9223372036854775808'::int8); +ERROR: bigint out of range +select '9223372036854775800'::int8 + '100'::int4; +ERROR: bigint out of range +select '-9223372036854775800'::int8 - '100'::int4; +ERROR: bigint out of range +select '9223372036854775800'::int8 * '100'::int4; +ERROR: bigint out of range +select '100'::int4 + '9223372036854775800'::int8; +ERROR: bigint out of range +select '-100'::int4 - '9223372036854775800'::int8; +ERROR: bigint out of range +select '100'::int4 * '9223372036854775800'::int8; +ERROR: bigint out of range +select '9223372036854775800'::int8 + '100'::int2; +ERROR: bigint out of range +select '-9223372036854775800'::int8 - '100'::int2; +ERROR: bigint out of range +select '9223372036854775800'::int8 * '100'::int2; +ERROR: bigint out of range +select '-9223372036854775808'::int8 / '0'::int2; +ERROR: division by zero +select '100'::int2 + '9223372036854775800'::int8; +ERROR: bigint out of range +select '-100'::int2 - '9223372036854775800'::int8; +ERROR: bigint out of range +select '100'::int2 * '9223372036854775800'::int8; +ERROR: bigint out of range +select '100'::int2 / '0'::int8; +ERROR: division by zero +SELECT CAST(q1 AS int4) FROM int8_tbl WHERE q2 = 456 ORDER BY q1; + q1 +----- + 123 +(1 row) + +SELECT CAST(q1 AS int4) FROM int8_tbl WHERE q2 <> 456 ORDER BY q1; +ERROR: integer out of range +SELECT CAST(q1 AS int2) FROM int8_tbl WHERE q2 = 456 ORDER BY q1; + q1 +----- + 123 +(1 row) + +SELECT CAST(q1 AS int2) FROM int8_tbl WHERE q2 <> 456 ORDER BY q1; +ERROR: smallint out of range +SELECT CAST('42'::int2 AS int8), CAST('-37'::int2 AS int8); + int8 | int8 +------+------ + 42 | -37 +(1 row) + +SELECT CAST(q1 AS float4), CAST(q2 AS float8) FROM INT8_TBL ORDER BY q1,q2; + q1 | q2 +-------------+----------------------- + 123 | 456 + 123 | 4.56789012345679e+15 + 4.56789e+15 | -4.56789012345679e+15 + 4.56789e+15 | 123 + 4.56789e+15 | 4.56789012345679e+15 +(5 rows) + +SELECT CAST('36854775807.0'::float4 AS int8); + int8 +------------- + 36854775808 +(1 row) + +SELECT CAST('922337203685477580700.0'::float8 AS int8); +ERROR: bigint out of range +SELECT CAST(q1 AS oid) FROM INT8_TBL ORDER BY q1; +ERROR: OID out of range +SELECT oid::int8 FROM pg_class WHERE relname = 'pg_class' ORDER BY oid; + oid +------ + 1259 +(1 row) + +-- bit operations +SELECT q1, q2, q1 & q2 AS "and", q1 | q2 AS "or", q1 # q2 AS "xor", ~q1 AS "not" FROM INT8_TBL ORDER BY q1,q2; + q1 | q2 | and | or | xor | not +------------------+-------------------+------------------+------------------+------------------+------------------- + 123 | 456 | 72 | 507 | 435 | -124 + 123 | 4567890123456789 | 17 | 4567890123456895 | 4567890123456878 | -124 + 4567890123456789 | -4567890123456789 | 1 | -1 | -2 | -4567890123456790 + 4567890123456789 | 123 | 17 | 4567890123456895 | 4567890123456878 | -4567890123456790 + 4567890123456789 | 4567890123456789 | 4567890123456789 | 4567890123456789 | 0 | -4567890123456790 +(5 rows) + +SELECT q1, q1 << 2 AS "shl", q1 >> 3 AS "shr" FROM INT8_TBL ORDER BY q1; + q1 | shl | shr +------------------+-------------------+----------------- + 123 | 492 | 15 + 123 | 492 | 15 + 4567890123456789 | 18271560493827156 | 570986265432098 + 4567890123456789 | 18271560493827156 | 570986265432098 + 4567890123456789 | 18271560493827156 | 570986265432098 +(5 rows) + +-- generate_series +SELECT * FROM generate_series('+4567890123456789'::int8, '+4567890123456799'::int8); + generate_series +------------------ + 4567890123456789 + 4567890123456790 + 4567890123456791 + 4567890123456792 + 4567890123456793 + 4567890123456794 + 4567890123456795 + 4567890123456796 + 4567890123456797 + 4567890123456798 + 4567890123456799 +(11 rows) + +SELECT * FROM generate_series('+4567890123456789'::int8, '+4567890123456799'::int8, 0); +ERROR: step size cannot equal zero +SELECT * FROM generate_series('+4567890123456789'::int8, '+4567890123456799'::int8, 2); + generate_series +------------------ + 4567890123456789 + 4567890123456791 + 4567890123456793 + 4567890123456795 + 4567890123456797 + 4567890123456799 +(6 rows) + diff --git a/src/test/regress/expected/tablespace_1.out b/src/test/regress/expected/tablespace_1.out new file mode 100644 index 0000000..725ad23 --- /dev/null +++ b/src/test/regress/expected/tablespace_1.out @@ -0,0 +1,98 @@ +-- create a tablespace we can use +CREATE TABLESPACE testspace LOCATION '/home/abbas/pgxc/postgres-xc/src/test/regress/testtablespace'; +ERROR: Postgres-XC does not support TABLESPACE yet +DETAIL: The feature is not currently supported +-- try setting and resetting some properties for the new tablespace +ALTER TABLESPACE testspace SET (random_page_cost = 1.0); +ERROR: tablespace "testspace" does not exist +ALTER TABLESPACE testspace SET (some_nonexistent_parameter = true); -- fail +ERROR: tablespace "testspace" does not exist +ALTER TABLESPACE testspace RESET (random_page_cost = 2.0); -- fail +ERROR: tablespace "testspace" does not exist +ALTER TABLESPACE testspace RESET (random_page_cost, seq_page_cost); -- ok +ERROR: tablespace "testspace" does not exist +-- create a schema we can use +CREATE SCHEMA testschema; +-- try a table +CREATE TABLE testschema.foo (i int) TABLESPACE testspace; +ERROR: tablespace "testspace" does not exist +SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c + where c.reltablespace = t.oid AND c.relname = 'foo'; + relname | spcname +---------+--------- +(0 rows) + +INSERT INTO testschema.foo VALUES(1); +ERROR: relation "testschema.foo" does not exist +LINE 1: INSERT INTO testschema.foo VALUES(1); + ^ +INSERT INTO testschema.foo VALUES(2); +ERROR: relation "testschema.foo" does not exist +LINE 1: INSERT INTO testschema.foo VALUES(2); + ^ +-- tables from dynamic sources +CREATE TABLE testschema.asselect TABLESPACE testspace AS SELECT 1; +ERROR: INTO clause not yet supported +SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c + where c.reltablespace = t.oid AND c.relname = 'asselect'; + relname | spcname +---------+--------- +(0 rows) + +PREPARE selectsource(int) AS SELECT $1; +ERROR: Postgres-XC does not support PREPARE yet +DETAIL: The feature is not currently supported +CREATE TABLE testschema.asexecute TABLESPACE testspace + AS EXECUTE selectsource(2); +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c + where c.reltablespace = t.oid AND c.relname = 'asexecute'; + relname | spcname +---------+--------- +(0 rows) + +-- index +CREATE INDEX foo_idx on testschema.foo(i) TABLESPACE testspace; +ERROR: relation "testschema.foo" does not exist +SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c + where c.reltablespace = t.oid AND c.relname = 'foo_idx'; + relname | spcname +---------+--------- +(0 rows) + +-- let's try moving a table from one place to another +CREATE TABLE testschema.atable AS VALUES (1), (2); +ERROR: INTO clause not yet supported +CREATE UNIQUE INDEX anindex ON testschema.atable(column1); +ERROR: relation "testschema.atable" does not exist +ALTER TABLE testschema.atable SET TABLESPACE testspace; +ERROR: relation "testschema.atable" does not exist +ALTER INDEX testschema.anindex SET TABLESPACE testspace; +ERROR: relation "testschema.anindex" does not exist +INSERT INTO testschema.atable VALUES(3); -- ok +ERROR: relation "testschema.atable" does not exist +LINE 1: INSERT INTO testschema.atable VALUES(3); + ^ +INSERT INTO testschema.atable VALUES(1); -- fail (checks index) +ERROR: relation "testschema.atable" does not exist +LINE 1: INSERT INTO testschema.atable VALUES(1); + ^ +SELECT COUNT(*) FROM testschema.atable; -- checks heap +ERROR: relation "testschema.atable" does not exist +LINE 1: SELECT COUNT(*) FROM testschema.atable; + ^ +-- Will fail with bad path +CREATE TABLESPACE badspace LOCATION '/no/such/location'; +ERROR: Postgres-XC does not support TABLESPACE yet +DETAIL: The feature is not currently supported +-- No such tablespace +CREATE TABLE bar (i int) TABLESPACE nosuchspace; +ERROR: tablespace "nosuchspace" does not exist +-- Fail, not empty +DROP TABLESPACE testspace; +ERROR: tablespace "testspace" does not exist +DROP SCHEMA testschema CASCADE; +-- Should succeed +DROP TABLESPACE testspace; +ERROR: tablespace "testspace" does not exist ----------------------------------------------------------------------- Summary of changes: src/test/regress/expected/{int8.out => int8_1.out} | 4 +- .../tablespace_1.out} | 82 ++++++++++++-------- 2 files changed, 51 insertions(+), 35 deletions(-) copy src/test/regress/expected/{int8.out => int8_1.out} (99%) copy src/test/regress/{output/tablespace.source => expected/tablespace_1.out} (53%) hooks/post-receive -- Postgres-XC |
From: Abbas B. <ga...@us...> - 2011-03-17 15:57:27
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via bce5904c777b305c7706146077c2a692e7dad52e (commit) from 2f96f59952551d1644c3176e5a23483308e9c810 (commit) - Log ----------------------------------------------------------------- commit bce5904c777b305c7706146077c2a692e7dad52e Author: Abbas <abb...@en...> Date: Thu Mar 17 20:55:15 2011 +0500 Fixing a few expected output files and changed a warning message to make the output independent of the cluster configuration diff --git a/src/backend/pgxc/pool/pgxcnode.c b/src/backend/pgxc/pool/pgxcnode.c index 58a089e..7baddd3 100644 --- a/src/backend/pgxc/pool/pgxcnode.c +++ b/src/backend/pgxc/pool/pgxcnode.c @@ -6,7 +6,7 @@ * Datanodes and Coordinators * * - * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 2010-2011 Nippon Telegraph and Telephone Corporation * * IDENTIFICATION @@ -607,7 +607,7 @@ release_handles(void) dn_discard[dn_ndisc++] = handle->nodenum; else if (handle->state != DN_CONNECTION_STATE_IDLE) { - elog(WARNING, "Connection to Datanode %d has unexpected state %d and will be dropped", handle->nodenum, handle->state); + elog(DEBUG1, "Connection to Datanode %d has unexpected state %d and will be dropped", handle->nodenum, handle->state); dn_discard[dn_ndisc++] = handle->nodenum; } pgxc_node_free(handle); @@ -625,7 +625,7 @@ release_handles(void) co_discard[co_ndisc++] = handle->nodenum; else if (handle->state != DN_CONNECTION_STATE_IDLE) { - elog(WARNING, "Connection to Coordinator %d has unexpected state %d and will be dropped", handle->nodenum, handle->state); + elog(DEBUG1, "Connection to Coordinator %d has unexpected state %d and will be dropped", handle->nodenum, handle->state); co_discard[co_ndisc++] = handle->nodenum; } pgxc_node_free(handle); diff --git a/src/test/regress/expected/char_1.out b/src/test/regress/expected/char_1.out index 4cc081d..1c38b33 100644 --- a/src/test/regress/expected/char_1.out +++ b/src/test/regress/expected/char_1.out @@ -25,28 +25,28 @@ INSERT INTO CHAR_TBL (f1) VALUES (''); INSERT INTO CHAR_TBL (f1) VALUES ('cd'); ERROR: value too long for type character(1) INSERT INTO CHAR_TBL (f1) VALUES ('c '); -SELECT '' AS seven, * FROM CHAR_TBL; +SELECT '' AS seven, * FROM CHAR_TBL ORDER BY f1; seven | f1 -------+---- - | a - | A + | | 1 | 2 | 3 - | + | a + | A | c (7 rows) SELECT '' AS six, c.* FROM CHAR_TBL c - WHERE c.f1 <> 'a'; + WHERE c.f1 <> 'a' ORDER BY f1; six | f1 -----+---- - | A + | | 1 | 2 | 3 - | + | A | c (6 rows) @@ -60,30 +60,30 @@ SELECT '' AS one, c.* SELECT '' AS five, c.* FROM CHAR_TBL c - WHERE c.f1 < 'a'; + WHERE c.f1 < 'a' ORDER BY f1; five | f1 ------+---- + | | 1 | 2 | 3 - | (4 rows) SELECT '' AS six, c.* FROM CHAR_TBL c - WHERE c.f1 <= 'a'; + WHERE c.f1 <= 'a' ORDER BY f1; six | f1 -----+---- - | a + | | 1 | 2 | 3 - | + | a (5 rows) SELECT '' AS one, c.* FROM CHAR_TBL c - WHERE c.f1 > 'a'; + WHERE c.f1 > 'a' ORDER BY f1; one | f1 -----+---- | A @@ -92,7 +92,7 @@ SELECT '' AS one, c.* SELECT '' AS two, c.* FROM CHAR_TBL c - WHERE c.f1 >= 'a'; + WHERE c.f1 >= 'a' ORDER BY f1; two | f1 -----+---- | a @@ -111,7 +111,7 @@ INSERT INTO CHAR_TBL (f1) VALUES ('abcd'); INSERT INTO CHAR_TBL (f1) VALUES ('abcde'); ERROR: value too long for type character(4) INSERT INTO CHAR_TBL (f1) VALUES ('abcd '); -SELECT '' AS four, * FROM CHAR_TBL; +SELECT '' AS four, * FROM CHAR_TBL ORDER BY f1; four | f1 ------+------ | a diff --git a/src/test/regress/expected/float8.out b/src/test/regress/expected/float8.out index d3e60cd..98a4d26 100644 --- a/src/test/regress/expected/float8.out +++ b/src/test/regress/expected/float8.out @@ -175,15 +175,6 @@ SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE '1004.3' >= f.f1 ORDER BY f1; | 1004.3 (4 rows) -SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE f.f1 <= '1004.3' ORDER BY f1; - four | f1 -------+---------------------- - | -34.84 - | 0 - | 1.2345678901234e-200 - | 1004.3 -(4 rows) - SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE f.f1 <= '1004.3'; four | f1 ------+---------------------- diff --git a/src/test/regress/expected/varchar_1.out b/src/test/regress/expected/varchar_1.out index d726e4c..29e7481 100644 --- a/src/test/regress/expected/varchar_1.out +++ b/src/test/regress/expected/varchar_1.out @@ -14,28 +14,28 @@ INSERT INTO VARCHAR_TBL (f1) VALUES (''); INSERT INTO VARCHAR_TBL (f1) VALUES ('cd'); ERROR: value too long for type character varying(1) INSERT INTO VARCHAR_TBL (f1) VALUES ('c '); -SELECT '' AS seven, * FROM VARCHAR_TBL; +SELECT '' AS seven, * FROM VARCHAR_TBL ORDER BY f1; seven | f1 -------+---- - | a - | A + | | 1 | 2 | 3 - | + | a + | A | c (7 rows) SELECT '' AS six, c.* FROM VARCHAR_TBL c - WHERE c.f1 <> 'a'; + WHERE c.f1 <> 'a' ORDER BY f1; six | f1 -----+---- - | A + | | 1 | 2 | 3 - | + | A | c (6 rows) @@ -49,25 +49,25 @@ SELECT '' AS one, c.* SELECT '' AS five, c.* FROM VARCHAR_TBL c - WHERE c.f1 < 'a'; + WHERE c.f1 < 'a' ORDER BY f1; five | f1 ------+---- + | | 1 | 2 | 3 - | (4 rows) SELECT '' AS six, c.* FROM VARCHAR_TBL c - WHERE c.f1 <= 'a'; + WHERE c.f1 <= 'a' ORDER BY f1; six | f1 -----+---- - | a + | | 1 | 2 | 3 - | + | a (5 rows) SELECT '' AS one, c.* @@ -81,7 +81,7 @@ SELECT '' AS one, c.* SELECT '' AS two, c.* FROM VARCHAR_TBL c - WHERE c.f1 >= 'a'; + WHERE c.f1 >= 'a' ORDER BY f1; two | f1 -----+---- | a @@ -100,7 +100,7 @@ INSERT INTO VARCHAR_TBL (f1) VALUES ('abcd'); INSERT INTO VARCHAR_TBL (f1) VALUES ('abcde'); ERROR: value too long for type character varying(4) INSERT INTO VARCHAR_TBL (f1) VALUES ('abcd '); -SELECT '' AS four, * FROM VARCHAR_TBL; +SELECT '' AS four, * FROM VARCHAR_TBL ORDER BY f1; four | f1 ------+------ | a ----------------------------------------------------------------------- Summary of changes: src/backend/pgxc/pool/pgxcnode.c | 6 +++--- src/test/regress/expected/char_1.out | 30 +++++++++++++++--------------- src/test/regress/expected/float8.out | 9 --------- src/test/regress/expected/varchar_1.out | 28 ++++++++++++++-------------- 4 files changed, 32 insertions(+), 41 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-11 05:45:57
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 2f96f59952551d1644c3176e5a23483308e9c810 (commit) from 861f5131ddadd10fcd88f3653862601cddf0b255 (commit) - Log ----------------------------------------------------------------- commit 2f96f59952551d1644c3176e5a23483308e9c810 Author: Michael P <mic...@us...> Date: Fri Mar 11 14:36:32 2011 +0900 Stabilize code for pg_regress tests This commits enables FOREIGN constraints and solves a couple of issues found with pg_regress tests when assertions are enabled. diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c index bdb026d..a3956ae 100644 --- a/src/backend/optimizer/plan/subselect.c +++ b/src/backend/optimizer/plan/subselect.c @@ -32,7 +32,9 @@ #include "utils/builtins.h" #include "utils/lsyscache.h" #include "utils/syscache.h" - +#ifdef PGXC +#include "pgxc/pgxc.h" +#endif typedef struct convert_testexpr_context { @@ -342,6 +344,11 @@ make_subplan(PlannerInfo *root, Query *orig_subquery, SubLinkType subLinkType, result = build_subplan(root, plan, subroot->parse->rtable, subroot->rowMarks, subLinkType, testexpr, true, isTopQual); +#ifdef PGXC + /* This is not necessary for a PGXC Coordinator, we just need one plan */ + if (IS_PGXC_COORDINATOR && !IsConnFromCoord()) + return result; +#endif /* * If it's a correlated EXISTS with an unimportant targetlist, we might be diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 3ffc570..0ed66ed 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -1595,12 +1595,6 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt, constraint->skip_validation = true; #ifdef PGXC - if (constraint->contype == CONSTR_FOREIGN) - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("Postgres-XC does not support FOREIGN constraints yet"), - errdetail("The feature is not currently supported"))); - /* * Set fallback distribution column. * If not yet set, set it to first column in FK constraint @@ -1611,7 +1605,8 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt, Oid pk_rel_id = RangeVarGetRelid(constraint->pktable, false); /* make sure it is a partitioned column */ - if (IsHashColumnForRelId(pk_rel_id, strVal(list_nth(constraint->pk_attrs,0)))) + if (list_length(constraint->pk_attrs) != 0 + && IsHashColumnForRelId(pk_rel_id, strVal(list_nth(constraint->pk_attrs,0)))) { /* take first column */ char *colstr = strdup(strVal(list_nth(constraint->fk_attrs,0))); @@ -2147,12 +2142,6 @@ transformAlterTableStmt(AlterTableStmt *stmt, const char *queryString) if (((Constraint *) cmd->def)->contype == CONSTR_FOREIGN) { skipValidation = false; -#ifdef PGXC - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("Postgres-XC does not support FOREIGN constraints yet"), - errdetail("The feature is not currently supported"))); -#endif } } else @@ -2557,8 +2546,8 @@ CheckLocalIndexColumn (char loctype, char *partcolname, char *indexcolname) * check to see if the constraint can be enforced locally * if not, an error will be thrown */ -void -static checkLocalFKConstraints(CreateStmtContext *cxt) +static void +checkLocalFKConstraints(CreateStmtContext *cxt) { ListCell *fkclist; @@ -2621,7 +2610,7 @@ static checkLocalFKConstraints(CreateStmtContext *cxt) { char *attrname = (char *) strVal(lfirst(attritem)); - if (strcmp(cxt->rel->rd_locator_info->partAttrName, attrname) == 0) + if (strcmp(checkcolname, attrname) == 0) { /* Found the ordinal position in constraint */ break; @@ -2631,14 +2620,20 @@ static checkLocalFKConstraints(CreateStmtContext *cxt) if (pos >= list_length(fkconstraint->fk_attrs)) ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("Hash/Modulo distributed table must include distribution column in index"))); + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("Hash/Modulo distributed table must include distribution column in index"))); + + /* Manage the error when the list of new constraints is empty */ + if (!fkconstraint->pk_attrs) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("Hash/Modulo distribution column list of attributes is empty"))); /* Verify that the referenced table is partitioned at the same position in the index */ if (!IsDistColumnForRelId(pk_rel_id, strVal(list_nth(fkconstraint->pk_attrs,pos)))) ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("Hash/Modulo distribution column does not refer to hash/modulo distribution column in referenced table."))); + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("Hash/Modulo distribution column does not refer to hash/modulo distribution column in referenced table."))); } } } ----------------------------------------------------------------------- Summary of changes: src/backend/optimizer/plan/subselect.c | 9 +++++++- src/backend/parser/parse_utilcmd.c | 35 +++++++++++++------------------ 2 files changed, 23 insertions(+), 21 deletions(-) hooks/post-receive -- Postgres-XC |
From: Abbas B. <ga...@us...> - 2011-03-10 17:23:59
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 861f5131ddadd10fcd88f3653862601cddf0b255 (commit) from 0461384764ef25c8248e8d22ec09a23d3cd608a3 (commit) - Log ----------------------------------------------------------------- commit 861f5131ddadd10fcd88f3653862601cddf0b255 Author: Abbas <abb...@en...> Date: Thu Mar 10 22:22:53 2011 +0500 The test case portals finds a NULL connecction in ExecEndRemoteQuery and crashes the server. This patch puts a NULL check to avoid the crash diff --git a/src/backend/pgxc/pool/execRemote.c b/src/backend/pgxc/pool/execRemote.c index af2f80c..7f53a22 100644 --- a/src/backend/pgxc/pool/execRemote.c +++ b/src/backend/pgxc/pool/execRemote.c @@ -3801,6 +3801,13 @@ ExecEndRemoteQuery(RemoteQueryState *node) pfree(node->currentRow.msg); node->currentRow.msg = NULL; } + + if (conn == NULL) + { + node->conn_count--; + continue; + } + /* no data is expected */ if (conn->state == DN_CONNECTION_STATE_IDLE || conn->state == DN_CONNECTION_STATE_ERROR_FATAL) ----------------------------------------------------------------------- Summary of changes: src/backend/pgxc/pool/execRemote.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-10 09:22:55
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 0461384764ef25c8248e8d22ec09a23d3cd608a3 (commit) from 95854dc24142a7ee751c05d658f52d84fc0649dc (commit) - Log ----------------------------------------------------------------- commit 0461384764ef25c8248e8d22ec09a23d3cd608a3 Author: Michael P <mic...@us...> Date: Thu Mar 10 18:19:26 2011 +0900 Fix for bug 3202643: Sequence error For the following sequence: create SEQUENCE seq; select nextval('seq'); select currval('seq'); select nextval('seq'); XC was returning 1 -> 100 -> 100 -> 101 PostgreSQL was returning 1 -> 100 -> 1 -> 100 This is corrected. We also check if nextval has been called once in a session when using currval. This is to correspond with PostgreSQL. diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c index ee19184..8a921f5 100644 --- a/src/backend/commands/sequence.c +++ b/src/backend/commands/sequence.c @@ -618,7 +618,13 @@ nextval_internal(Oid relid) /* Update the on-disk data */ seq->last_value = result; /* last fetched number */ seq->is_called = true; - } else + + /* save info in local cache */ + elm->last = result; /* last returned number */ + elm->cached = result; /* last fetched number */ + elm->last_valid = true; + } + else { #endif last = next = result = seq->last_value; @@ -798,21 +804,6 @@ currval_oid(PG_FUNCTION_ARGS) /* open and AccessShareLock sequence */ init_sequence(relid, &elm, &seqrel); -#ifdef PGXC - if (IS_PGXC_COORDINATOR) - { - char *seqname = GetGlobalSeqName(seqrel, NULL, NULL); - - result = (int64) GetCurrentValGTM(seqname); - if (result < 0) - ereport(ERROR, - (errcode(ERRCODE_CONNECTION_FAILURE), - errmsg("GTM error, could not obtain sequence value"))); - pfree(seqname); - } - else - { -#endif if (pg_class_aclcheck(elm->relid, GetUserId(), ACL_SELECT) != ACLCHECK_OK && pg_class_aclcheck(elm->relid, GetUserId(), ACL_USAGE) != ACLCHECK_OK) @@ -827,12 +818,21 @@ currval_oid(PG_FUNCTION_ARGS) errmsg("currval of sequence \"%s\" is not yet defined in this session", RelationGetRelationName(seqrel)))); - result = elm->last; - #ifdef PGXC + if (IS_PGXC_COORDINATOR) + { + char *seqname = GetGlobalSeqName(seqrel, NULL, NULL); + + result = (int64) GetCurrentValGTM(seqname); + if (result < 0) + ereport(ERROR, + (errcode(ERRCODE_CONNECTION_FAILURE), + errmsg("GTM error, could not obtain sequence value"))); + pfree(seqname); } +#else + result = elm->last; #endif - relation_close(seqrel, NoLock); PG_RETURN_INT64(result); diff --git a/src/gtm/main/gtm_seq.c b/src/gtm/main/gtm_seq.c index 9ea5672..8c15fe9 100644 --- a/src/gtm/main/gtm_seq.c +++ b/src/gtm/main/gtm_seq.c @@ -660,16 +660,8 @@ GTM_SeqGetCurrent(GTM_SequenceKey seqkey) GTM_RWLockAcquire(&seqinfo->gs_lock, GTM_LOCKMODE_WRITE); - /* - * If this is the first call to the sequence, set the value to the start - * value and mark the sequence as 'called' - */ - if (!SEQ_IS_CALLED(seqinfo)) - { - seqinfo->gs_value = seqinfo->gs_init_value; - seqinfo->gs_called = true; - } - value = seqinfo->gs_value; + value = seqinfo->gs_last_value; + GTM_RWLockRelease(&seqinfo->gs_lock); seq_release_seqinfo(seqinfo); return value; @@ -693,6 +685,8 @@ GTM_SeqSetVal(GTM_SequenceKey seqkey, GTM_Sequence nextval, bool iscalled) GTM_RWLockAcquire(&seqinfo->gs_lock, GTM_LOCKMODE_WRITE); + seqinfo->gs_last_value = seqinfo->gs_value; + if (seqinfo->gs_value != nextval) seqinfo->gs_value = nextval; @@ -734,7 +728,7 @@ GTM_SeqGetNext(GTM_SequenceKey seqkey) */ if (!SEQ_IS_CALLED(seqinfo)) { - value = seqinfo->gs_value = seqinfo->gs_init_value; + value = seqinfo->gs_last_value = seqinfo->gs_value = seqinfo->gs_init_value; seqinfo->gs_called = true; GTM_RWLockRelease(&seqinfo->gs_lock); seq_release_seqinfo(seqinfo); @@ -749,9 +743,9 @@ GTM_SeqGetNext(GTM_SequenceKey seqkey) * InvalidSequenceValue */ if (seqinfo->gs_max_value - seqinfo->gs_increment_by >= seqinfo->gs_value) - value = seqinfo->gs_value = seqinfo->gs_value + seqinfo->gs_increment_by; + value = seqinfo->gs_last_value = seqinfo->gs_value = seqinfo->gs_value + seqinfo->gs_increment_by; else if (SEQ_IS_CYCLE(seqinfo)) - value = seqinfo->gs_value = seqinfo->gs_min_value; + value = seqinfo->gs_last_value = seqinfo->gs_value = seqinfo->gs_min_value; else { GTM_RWLockRelease(&seqinfo->gs_lock); @@ -774,9 +768,9 @@ GTM_SeqGetNext(GTM_SequenceKey seqkey) * descending sequences. So we don't need special handling below */ if (seqinfo->gs_min_value - seqinfo->gs_increment_by <= seqinfo->gs_value) - value = seqinfo->gs_value = seqinfo->gs_value + seqinfo->gs_increment_by; + value = seqinfo->gs_value = seqinfo->gs_last_value = seqinfo->gs_value + seqinfo->gs_increment_by; else if (SEQ_IS_CYCLE(seqinfo)) - value = seqinfo->gs_value = seqinfo->gs_max_value; + value = seqinfo->gs_value = seqinfo->gs_last_value = seqinfo->gs_max_value; else { GTM_RWLockRelease(&seqinfo->gs_lock); @@ -810,7 +804,7 @@ GTM_SeqReset(GTM_SequenceKey seqkey) } GTM_RWLockAcquire(&seqinfo->gs_lock, GTM_LOCKMODE_WRITE); - seqinfo->gs_value = seqinfo->gs_init_value; + seqinfo->gs_value = seqinfo->gs_last_value = seqinfo->gs_init_value; GTM_RWLockRelease(&seqinfo->gs_lock); seq_release_seqinfo(seqinfo); ----------------------------------------------------------------------- Summary of changes: src/backend/commands/sequence.c | 38 +++++++++++++++++++------------------- src/gtm/main/gtm_seq.c | 26 ++++++++++---------------- 2 files changed, 29 insertions(+), 35 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-10 06:09:49
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 95854dc24142a7ee751c05d658f52d84fc0649dc (commit) from e0df08e39ab62378dcb7d11e259c5e1474104e0f (commit) - Log ----------------------------------------------------------------- commit 95854dc24142a7ee751c05d658f52d84fc0649dc Author: Michael P <mic...@us...> Date: Thu Mar 10 15:08:11 2011 +0900 Fix for regression test box It is not possible to use ORDER BY for an object of type box, so the output file for 2 Datanodes is added. diff --git a/src/test/regress/expected/box_1.out b/src/test/regress/expected/box_1.out new file mode 100644 index 0000000..7bd428a --- /dev/null +++ b/src/test/regress/expected/box_1.out @@ -0,0 +1,218 @@ +-- +-- BOX +-- +-- +-- box logic +-- o +-- 3 o--|X +-- | o| +-- 2 +-+-+ | +-- | | | | +-- 1 | o-+-o +-- | | +-- 0 +---+ +-- +-- 0 1 2 3 +-- +-- boxes are specified by two points, given by four floats x1,y1,x2,y2 +CREATE TABLE BOX_TBL (f1 box); +INSERT INTO BOX_TBL (f1) VALUES ('(2.0,2.0,0.0,0.0)'); +INSERT INTO BOX_TBL (f1) VALUES ('(1.0,1.0,3.0,3.0)'); +-- degenerate cases where the box is a line or a point +-- note that lines and points boxes all have zero area +INSERT INTO BOX_TBL (f1) VALUES ('(2.5, 2.5, 2.5,3.5)'); +INSERT INTO BOX_TBL (f1) VALUES ('(3.0, 3.0,3.0,3.0)'); +-- badly formatted box inputs +INSERT INTO BOX_TBL (f1) VALUES ('(2.3, 4.5)'); +ERROR: invalid input syntax for type box: "(2.3, 4.5)" +LINE 1: INSERT INTO BOX_TBL (f1) VALUES ('(2.3, 4.5)'); + ^ +INSERT INTO BOX_TBL (f1) VALUES ('asdfasdf(ad'); +ERROR: invalid input syntax for type box: "asdfasdf(ad" +LINE 1: INSERT INTO BOX_TBL (f1) VALUES ('asdfasdf(ad'); + ^ +SELECT '' AS four, * FROM BOX_TBL; + four | f1 +------+--------------------- + | (3,3),(1,1) + | (3,3),(3,3) + | (2,2),(0,0) + | (2.5,3.5),(2.5,2.5) +(4 rows) + +SELECT '' AS four, b.*, area(b.f1) as barea + FROM BOX_TBL b ORDER BY (b.f1[0])[0], (b.f1[0])[1], (b.f1[2])[0], (b.f1[2])[1]; + four | f1 | barea +------+---------------------+------- + | (2,2),(0,0) | 4 + | (2.5,3.5),(2.5,2.5) | 0 + | (3,3),(1,1) | 4 + | (3,3),(3,3) | 0 +(4 rows) + +-- overlap +SELECT '' AS three, b.f1 + FROM BOX_TBL b + WHERE b.f1 && box '(2.5,2.5,1.0,1.0)' ORDER BY (b.f1[0])[0], (b.f1[0])[1], (b.f1[2])[0], (b.f1[2])[1]; + three | f1 +-------+--------------------- + | (2,2),(0,0) + | (2.5,3.5),(2.5,2.5) + | (3,3),(1,1) +(3 rows) + +-- left-or-overlap (x only) +SELECT '' AS two, b1.* + FROM BOX_TBL b1 + WHERE b1.f1 &< box '(2.0,2.0,2.5,2.5)' ORDER BY (b1.f1[0])[0], (b1.f1[0])[1], (b1.f1[2])[0], (b1.f1[2])[1]; + two | f1 +-----+--------------------- + | (2,2),(0,0) + | (2.5,3.5),(2.5,2.5) +(2 rows) + +-- right-or-overlap (x only) +SELECT '' AS two, b1.* + FROM BOX_TBL b1 + WHERE b1.f1 &> box '(2.0,2.0,2.5,2.5)' ORDER BY (b1.f1[0])[0], (b1.f1[0])[1], (b1.f1[2])[0], (b1.f1[2])[1]; + two | f1 +-----+--------------------- + | (2.5,3.5),(2.5,2.5) + | (3,3),(3,3) +(2 rows) + +-- left of +SELECT '' AS two, b.f1 + FROM BOX_TBL b + WHERE b.f1 << box '(3.0,3.0,5.0,5.0)' ORDER BY (b.f1[0])[0], (b.f1[0])[1], (b.f1[2])[0], (b.f1[2])[1]; + two | f1 +-----+--------------------- + | (2,2),(0,0) + | (2.5,3.5),(2.5,2.5) +(2 rows) + +-- area <= +SELECT '' AS four, b.f1 + FROM BOX_TBL b + WHERE b.f1 <= box '(3.0,3.0,5.0,5.0)' ORDER BY (b.f1[0])[0], (b.f1[0])[1], (b.f1[2])[0], (b.f1[2])[1]; + four | f1 +------+--------------------- + | (2,2),(0,0) + | (2.5,3.5),(2.5,2.5) + | (3,3),(1,1) + | (3,3),(3,3) +(4 rows) + +-- area < +SELECT '' AS two, b.f1 + FROM BOX_TBL b + WHERE b.f1 < box '(3.0,3.0,5.0,5.0)' ORDER BY (b.f1[0])[0], (b.f1[0])[1], (b.f1[2])[0], (b.f1[2])[1]; + two | f1 +-----+--------------------- + | (2.5,3.5),(2.5,2.5) + | (3,3),(3,3) +(2 rows) + +-- area = +SELECT '' AS two, b.f1 + FROM BOX_TBL b + WHERE b.f1 = box '(3.0,3.0,5.0,5.0)' ORDER BY (b.f1[0])[0], (b.f1[0])[1], (b.f1[2])[0], (b.f1[2])[1]; + two | f1 +-----+------------- + | (2,2),(0,0) + | (3,3),(1,1) +(2 rows) + +-- area > +SELECT '' AS two, b.f1 + FROM BOX_TBL b -- zero area + WHERE b.f1 > box '(3.5,3.0,4.5,3.0)' ORDER BY (b.f1[0])[0], (b.f1[0])[1], (b.f1[2])[0], (b.f1[2])[1]; + two | f1 +-----+------------- + | (2,2),(0,0) + | (3,3),(1,1) +(2 rows) + +-- area >= +SELECT '' AS four, b.f1 + FROM BOX_TBL b -- zero area + WHERE b.f1 >= box '(3.5,3.0,4.5,3.0)' ORDER BY (b.f1[0])[0], (b.f1[0])[1], (b.f1[2])[0], (b.f1[2])[1]; + four | f1 +------+--------------------- + | (2,2),(0,0) + | (2.5,3.5),(2.5,2.5) + | (3,3),(1,1) + | (3,3),(3,3) +(4 rows) + +-- right of +SELECT '' AS two, b.f1 + FROM BOX_TBL b + WHERE box '(3.0,3.0,5.0,5.0)' >> b.f1 ORDER BY (b.f1[0])[0], (b.f1[0])[1], (b.f1[2])[0], (b.f1[2])[1]; + two | f1 +-----+--------------------- + | (2,2),(0,0) + | (2.5,3.5),(2.5,2.5) +(2 rows) + +-- contained in +SELECT '' AS three, b.f1 + FROM BOX_TBL b + WHERE b.f1 <@ box '(0,0,3,3)' ORDER BY (b.f1[0])[0], (b.f1[0])[1], (b.f1[2])[0], (b.f1[2])[1]; + three | f1 +-------+------------- + | (2,2),(0,0) + | (3,3),(1,1) + | (3,3),(3,3) +(3 rows) + +-- contains +SELECT '' AS three, b.f1 + FROM BOX_TBL b + WHERE box '(0,0,3,3)' @> b.f1 ORDER BY (b.f1[0])[0], (b.f1[0])[1], (b.f1[2])[0], (b.f1[2])[1]; + three | f1 +-------+------------- + | (2,2),(0,0) + | (3,3),(1,1) + | (3,3),(3,3) +(3 rows) + +-- box equality +SELECT '' AS one, b.f1 + FROM BOX_TBL b + WHERE box '(1,1,3,3)' ~= b.f1 ORDER BY (b.f1[0])[0], (b.f1[0])[1], (b.f1[2])[0], (b.f1[2])[1]; + one | f1 +-----+------------- + | (3,3),(1,1) +(1 row) + +-- center of box, left unary operator +SELECT '' AS four, @@(b1.f1) AS p + FROM BOX_TBL b1 ORDER BY (b1.f1[0])[0], (b1.f1[0])[1], (b1.f1[2])[0], (b1.f1[2])[1]; + four | p +------+--------- + | (1,1) + | (2.5,3) + | (2,2) + | (3,3) +(4 rows) + +-- wholly-contained +SELECT '' AS one, b1.*, b2.* + FROM BOX_TBL b1, BOX_TBL b2 + WHERE b1.f1 @> b2.f1 and not b1.f1 ~= b2.f1 + ORDER BY (b1.f1[0])[0], (b1.f1[0])[1], (b1.f1[2])[0], (b1.f1[2])[1], (b2.f1[0])[0], (b2.f1[0])[1], (b2.f1[2])[0], (b2.f1[2])[1]; + one | f1 | f1 +-----+-------------+------------- + | (3,3),(1,1) | (3,3),(3,3) +(1 row) + +SELECT '' AS four, height(f1), width(f1) FROM BOX_TBL ORDER BY (f1[0])[0], (f1[0])[1], (f1[2])[0], (f1[2])[1]; + four | height | width +------+--------+------- + | 2 | 2 + | 1 | 0 + | 2 | 2 + | 0 | 0 +(4 rows) + ----------------------------------------------------------------------- Summary of changes: src/test/regress/expected/{box.out => box_1.out} | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) copy src/test/regress/expected/{box.out => box_1.out} (100%) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-10 05:46:28
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via e0df08e39ab62378dcb7d11e259c5e1474104e0f (commit) from 09a00e32319f4af6f2cab879ed1fae866164eca5 (commit) - Log ----------------------------------------------------------------- commit e0df08e39ab62378dcb7d11e259c5e1474104e0f Author: Michael P <mic...@us...> Date: Thu Mar 10 14:42:35 2011 +0900 Fix for bug 3201711: Sequence view crash This query was pushed down to Datanodes, but it has to be launched on Local Coordinator. CREATE SEQUENCE foo; select * from foo; This fix is important for pg_admin. diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c index e812025..0497180 100644 --- a/src/backend/optimizer/path/allpaths.c +++ b/src/backend/optimizer/path/allpaths.c @@ -35,6 +35,7 @@ #include "parser/parsetree.h" #ifdef PGXC #include "catalog/pg_namespace.h" +#include "catalog/pg_class.h" #include "pgxc/pgxc.h" #endif #include "rewrite/rewriteManip.h" @@ -261,11 +262,13 @@ set_plain_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte) #ifdef PGXC /* * If we are on the coordinator, we always want to use - * the remote query path unless it is a pg_catalog table. + * the remote query path unless it is a pg_catalog table + * or a sequence relation. */ if (IS_PGXC_COORDINATOR && !IsConnFromCoord() && - get_rel_namespace(rte->relid) != PG_CATALOG_NAMESPACE) + get_rel_namespace(rte->relid) != PG_CATALOG_NAMESPACE && + get_rel_relkind(rte->relid) != RELKIND_SEQUENCE) add_path(rel, create_remotequery_path(root, rel)); else { diff --git a/src/backend/pgxc/plan/planner.c b/src/backend/pgxc/plan/planner.c index 622834e..e4d13cb 100644 --- a/src/backend/pgxc/plan/planner.c +++ b/src/backend/pgxc/plan/planner.c @@ -1573,7 +1573,13 @@ get_plan_nodes_walker(Node *query_node, XCWalkerContext *context) if (get_rel_namespace(rte->relid) == PG_CATALOG_NAMESPACE) current_usage_type = TABLE_USAGE_TYPE_PGCATALOG; else - current_usage_type = TABLE_USAGE_TYPE_USER; + { + /* Check if this relation is a sequence */ + if (get_rel_relkind(rte->relid) == RELKIND_SEQUENCE) + current_usage_type = TABLE_USAGE_TYPE_SEQUENCE; + else + current_usage_type = TABLE_USAGE_TYPE_USER; + } } else if (rte->rtekind == RTE_FUNCTION) { @@ -1607,11 +1613,12 @@ get_plan_nodes_walker(Node *query_node, XCWalkerContext *context) } } - /* If we are just dealing with pg_catalog, just return. */ - if (table_usage_type == TABLE_USAGE_TYPE_PGCATALOG) + /* If we are just dealing with pg_catalog or a sequence, just return. */ + if (table_usage_type == TABLE_USAGE_TYPE_PGCATALOG || + table_usage_type == TABLE_USAGE_TYPE_SEQUENCE) { context->query_step->exec_nodes = makeNode(ExecNodes); - context->query_step->exec_nodes->tableusagetype = TABLE_USAGE_TYPE_PGCATALOG; + context->query_step->exec_nodes->tableusagetype = table_usage_type; context->exec_on_coord = true; return false; } diff --git a/src/include/pgxc/locator.h b/src/include/pgxc/locator.h index 5948fae..3272ab6 100644 --- a/src/include/pgxc/locator.h +++ b/src/include/pgxc/locator.h @@ -39,6 +39,7 @@ typedef enum { TABLE_USAGE_TYPE_NO_TABLE, TABLE_USAGE_TYPE_PGCATALOG, + TABLE_USAGE_TYPE_SEQUENCE, TABLE_USAGE_TYPE_USER, TABLE_USAGE_TYPE_USER_REPLICATED, /* based on a replicated table */ TABLE_USAGE_TYPE_MIXED ----------------------------------------------------------------------- Summary of changes: src/backend/optimizer/path/allpaths.c | 7 +++++-- src/backend/pgxc/plan/planner.c | 15 +++++++++++---- src/include/pgxc/locator.h | 1 + 3 files changed, 17 insertions(+), 6 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-10 01:22:39
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 09a00e32319f4af6f2cab879ed1fae866164eca5 (commit) from baed9de74d766b401d088918e809dc9e51b313f7 (commit) - Log ----------------------------------------------------------------- commit 09a00e32319f4af6f2cab879ed1fae866164eca5 Author: Michael P <mic...@us...> Date: Thu Mar 10 10:21:19 2011 +0900 Block SERIAL sequences XC does not support yet serial sequences when creating tables. diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 1777199..3ffc570 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -362,6 +362,13 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, AlterSeqStmt *altseqstmt; List *attnamelist; +#ifdef PGXC + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("Postgres-XC does not support SERIAL yet"), + errdetail("The feature is not currently supported"))); +#endif + /* * Determine namespace and name to use for the sequence. * ----------------------------------------------------------------------- Summary of changes: src/backend/parser/parse_utilcmd.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) hooks/post-receive -- Postgres-XC |
From: Abbas B. <ga...@us...> - 2011-03-09 16:49:31
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via baed9de74d766b401d088918e809dc9e51b313f7 (commit) from 565200f09a592715c10cbbec578c6b74a25e2bc2 (commit) - Log ----------------------------------------------------------------- commit baed9de74d766b401d088918e809dc9e51b313f7 Author: Abbas <abb...@en...> Date: Wed Mar 9 21:50:22 2011 +0500 Block FK Constraints and add some missing checks diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 5b6ba6b..1777199 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -1552,7 +1552,9 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt) } #ifdef PGXC if (IS_PGXC_COORDINATOR && cxt->distributeby - && cxt->distributeby->disttype == DISTTYPE_HASH && !isLocalSafe) + && ( cxt->distributeby->disttype == DISTTYPE_HASH || + cxt->distributeby->disttype == DISTTYPE_MODULO) + && !isLocalSafe) ereport(ERROR, (errcode(ERRCODE_INVALID_COLUMN_REFERENCE), errmsg("Unique index of partitioned table must contain the hash distribution column."))); @@ -2136,7 +2138,15 @@ transformAlterTableStmt(AlterTableStmt *stmt, const char *queryString) transformTableConstraint(pstate, &cxt, (Constraint *) cmd->def); if (((Constraint *) cmd->def)->contype == CONSTR_FOREIGN) + { skipValidation = false; +#ifdef PGXC + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("Postgres-XC does not support FOREIGN constraints yet"), + errdetail("The feature is not currently supported"))); +#endif + } } else elog(ERROR, "unrecognized node type: %d", @@ -2583,7 +2593,8 @@ static checkLocalFKConstraints(CreateStmtContext *cxt) { if (cxt->distributeby) { - if (cxt->distributeby->disttype == DISTTYPE_HASH) + if (cxt->distributeby->disttype == DISTTYPE_HASH || + cxt->distributeby->disttype == DISTTYPE_MODULO) checkcolname = cxt->distributeby->colname; } else ----------------------------------------------------------------------- Summary of changes: src/backend/parser/parse_utilcmd.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-09 07:33:18
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 565200f09a592715c10cbbec578c6b74a25e2bc2 (commit) from d6beeda6a68cce6f74d179e3520443be2a29bb4d (commit) - Log ----------------------------------------------------------------- commit 565200f09a592715c10cbbec578c6b74a25e2bc2 Author: Michael P <mic...@us...> Date: Wed Mar 9 16:31:37 2011 +0900 Fix for regression test inet An ORDER BY is necessary to reorder output of a SELECT query. Output has also been updated. diff --git a/src/test/regress/expected/inet_1.out b/src/test/regress/expected/inet_1.out new file mode 100644 index 0000000..881770b --- /dev/null +++ b/src/test/regress/expected/inet_1.out @@ -0,0 +1,455 @@ +-- +-- INET +-- +-- prepare the table... +DROP TABLE INET_TBL; +ERROR: table "inet_tbl" does not exist +CREATE TABLE INET_TBL (c cidr, i inet); +INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.226/24'); +INSERT INTO INET_TBL (c, i) VALUES ('192.168.1.0/26', '192.168.1.226'); +INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.0/24'); +INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.0/25'); +INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.255/24'); +INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.255/25'); +INSERT INTO INET_TBL (c, i) VALUES ('10', '10.1.2.3/8'); +INSERT INTO INET_TBL (c, i) VALUES ('10.0.0.0', '10.1.2.3/8'); +INSERT INTO INET_TBL (c, i) VALUES ('10.1.2.3', '10.1.2.3/32'); +INSERT INTO INET_TBL (c, i) VALUES ('10.1.2', '10.1.2.3/24'); +INSERT INTO INET_TBL (c, i) VALUES ('10.1', '10.1.2.3/16'); +INSERT INTO INET_TBL (c, i) VALUES ('10', '10.1.2.3/8'); +INSERT INTO INET_TBL (c, i) VALUES ('10', '11.1.2.3/8'); +INSERT INTO INET_TBL (c, i) VALUES ('10', '9.1.2.3/8'); +INSERT INTO INET_TBL (c, i) VALUES ('10:23::f1', '10:23::f1/64'); +INSERT INTO INET_TBL (c, i) VALUES ('10:23::8000/113', '10:23::ffff'); +INSERT INTO INET_TBL (c, i) VALUES ('::ffff:1.2.3.4', '::4.3.2.1/24'); +-- check that CIDR rejects invalid input: +INSERT INTO INET_TBL (c, i) VALUES ('192.168.1.2/30', '192.168.1.226'); +ERROR: invalid cidr value: "192.168.1.2/30" +LINE 1: INSERT INTO INET_TBL (c, i) VALUES ('192.168.1.2/30', '192.1... + ^ +DETAIL: Value has bits set to right of mask. +INSERT INTO INET_TBL (c, i) VALUES ('1234::1234::1234', '::1.2.3.4'); +ERROR: invalid input syntax for type cidr: "1234::1234::1234" +LINE 1: INSERT INTO INET_TBL (c, i) VALUES ('1234::1234::1234', '::1... + ^ +-- check that CIDR rejects invalid input when converting from text: +INSERT INTO INET_TBL (c, i) VALUES (cidr('192.168.1.2/30'), '192.168.1.226'); +ERROR: invalid cidr value: "192.168.1.2/30" +LINE 1: INSERT INTO INET_TBL (c, i) VALUES (cidr('192.168.1.2/30'), ... + ^ +DETAIL: Value has bits set to right of mask. +INSERT INTO INET_TBL (c, i) VALUES (cidr('ffff:ffff:ffff:ffff::/24'), '::192.168.1.226'); +ERROR: invalid cidr value: "ffff:ffff:ffff:ffff::/24" +LINE 1: INSERT INTO INET_TBL (c, i) VALUES (cidr('ffff:ffff:ffff:fff... + ^ +DETAIL: Value has bits set to right of mask. +SELECT '' AS ten, c AS cidr, i AS inet FROM INET_TBL ORDER BY cidr; + ten | cidr | inet +-----+--------------------+------------------ + | 10.0.0.0/8 | 9.1.2.3/8 + | 10.0.0.0/8 | 11.1.2.3/8 + | 10.0.0.0/8 | 10.1.2.3/8 + | 10.0.0.0/8 | 10.1.2.3/8 + | 10.0.0.0/32 | 10.1.2.3/8 + | 10.1.0.0/16 | 10.1.2.3/16 + | 10.1.2.0/24 | 10.1.2.3/24 + | 10.1.2.3/32 | 10.1.2.3 + | 192.168.1.0/24 | 192.168.1.0/25 + | 192.168.1.0/24 | 192.168.1.226/24 + | 192.168.1.0/24 | 192.168.1.255/25 + | 192.168.1.0/24 | 192.168.1.0/24 + | 192.168.1.0/24 | 192.168.1.255/24 + | 192.168.1.0/26 | 192.168.1.226 + | ::ffff:1.2.3.4/128 | ::4.3.2.1/24 + | 10:23::f1/128 | 10:23::f1/64 + | 10:23::8000/113 | 10:23::ffff +(17 rows) + +-- now test some support functions +SELECT '' AS ten, i AS inet, host(i), text(i), family(i) FROM INET_TBL ORDER BY i; + ten | inet | host | text | family +-----+------------------+---------------+------------------+-------- + | 9.1.2.3/8 | 9.1.2.3 | 9.1.2.3/8 | 4 + | 10.1.2.3/8 | 10.1.2.3 | 10.1.2.3/8 | 4 + | 10.1.2.3/8 | 10.1.2.3 | 10.1.2.3/8 | 4 + | 10.1.2.3/8 | 10.1.2.3 | 10.1.2.3/8 | 4 + | 10.1.2.3/16 | 10.1.2.3 | 10.1.2.3/16 | 4 + | 10.1.2.3/24 | 10.1.2.3 | 10.1.2.3/24 | 4 + | 10.1.2.3 | 10.1.2.3 | 10.1.2.3/32 | 4 + | 11.1.2.3/8 | 11.1.2.3 | 11.1.2.3/8 | 4 + | 192.168.1.0/24 | 192.168.1.0 | 192.168.1.0/24 | 4 + | 192.168.1.226/24 | 192.168.1.226 | 192.168.1.226/24 | 4 + | 192.168.1.255/24 | 192.168.1.255 | 192.168.1.255/24 | 4 + | 192.168.1.0/25 | 192.168.1.0 | 192.168.1.0/25 | 4 + | 192.168.1.255/25 | 192.168.1.255 | 192.168.1.255/25 | 4 + | 192.168.1.226 | 192.168.1.226 | 192.168.1.226/32 | 4 + | ::4.3.2.1/24 | ::4.3.2.1 | ::4.3.2.1/24 | 6 + | 10:23::f1/64 | 10:23::f1 | 10:23::f1/64 | 6 + | 10:23::ffff | 10:23::ffff | 10:23::ffff/128 | 6 +(17 rows) + +SELECT '' AS ten, c AS cidr, broadcast(c), + i AS inet, broadcast(i) FROM INET_TBL ORDER BY i, c; + ten | cidr | broadcast | inet | broadcast +-----+--------------------+------------------+------------------+--------------------------------------- + | 10.0.0.0/8 | 10.255.255.255/8 | 9.1.2.3/8 | 9.255.255.255/8 + | 10.0.0.0/8 | 10.255.255.255/8 | 10.1.2.3/8 | 10.255.255.255/8 + | 10.0.0.0/8 | 10.255.255.255/8 | 10.1.2.3/8 | 10.255.255.255/8 + | 10.0.0.0/32 | 10.0.0.0 | 10.1.2.3/8 | 10.255.255.255/8 + | 10.1.0.0/16 | 10.1.255.255/16 | 10.1.2.3/16 | 10.1.255.255/16 + | 10.1.2.0/24 | 10.1.2.255/24 | 10.1.2.3/24 | 10.1.2.255/24 + | 10.1.2.3/32 | 10.1.2.3 | 10.1.2.3 | 10.1.2.3 + | 10.0.0.0/8 | 10.255.255.255/8 | 11.1.2.3/8 | 11.255.255.255/8 + | 192.168.1.0/24 | 192.168.1.255/24 | 192.168.1.0/24 | 192.168.1.255/24 + | 192.168.1.0/24 | 192.168.1.255/24 | 192.168.1.226/24 | 192.168.1.255/24 + | 192.168.1.0/24 | 192.168.1.255/24 | 192.168.1.255/24 | 192.168.1.255/24 + | 192.168.1.0/24 | 192.168.1.255/24 | 192.168.1.0/25 | 192.168.1.127/25 + | 192.168.1.0/24 | 192.168.1.255/24 | 192.168.1.255/25 | 192.168.1.255/25 + | 192.168.1.0/26 | 192.168.1.63/26 | 192.168.1.226 | 192.168.1.226 + | ::ffff:1.2.3.4/128 | ::ffff:1.2.3.4 | ::4.3.2.1/24 | 0:ff:ffff:ffff:ffff:ffff:ffff:ffff/24 + | 10:23::f1/128 | 10:23::f1 | 10:23::f1/64 | 10:23::ffff:ffff:ffff:ffff/64 + | 10:23::8000/113 | 10:23::ffff/113 | 10:23::ffff | 10:23::ffff +(17 rows) + +SELECT '' AS ten, c AS cidr, network(c) AS "network(cidr)", + i AS inet, network(i) AS "network(inet)" FROM INET_TBL ORDER BY i, c; + ten | cidr | network(cidr) | inet | network(inet) +-----+--------------------+--------------------+------------------+------------------ + | 10.0.0.0/8 | 10.0.0.0/8 | 9.1.2.3/8 | 9.0.0.0/8 + | 10.0.0.0/8 | 10.0.0.0/8 | 10.1.2.3/8 | 10.0.0.0/8 + | 10.0.0.0/8 | 10.0.0.0/8 | 10.1.2.3/8 | 10.0.0.0/8 + | 10.0.0.0/32 | 10.0.0.0/32 | 10.1.2.3/8 | 10.0.0.0/8 + | 10.1.0.0/16 | 10.1.0.0/16 | 10.1.2.3/16 | 10.1.0.0/16 + | 10.1.2.0/24 | 10.1.2.0/24 | 10.1.2.3/24 | 10.1.2.0/24 + | 10.1.2.3/32 | 10.1.2.3/32 | 10.1.2.3 | 10.1.2.3/32 + | 10.0.0.0/8 | 10.0.0.0/8 | 11.1.2.3/8 | 11.0.0.0/8 + | 192.168.1.0/24 | 192.168.1.0/24 | 192.168.1.0/24 | 192.168.1.0/24 + | 192.168.1.0/24 | 192.168.1.0/24 | 192.168.1.226/24 | 192.168.1.0/24 + | 192.168.1.0/24 | 192.168.1.0/24 | 192.168.1.255/24 | 192.168.1.0/24 + | 192.168.1.0/24 | 192.168.1.0/24 | 192.168.1.0/25 | 192.168.1.0/25 + | 192.168.1.0/24 | 192.168.1.0/24 | 192.168.1.255/25 | 192.168.1.128/25 + | 192.168.1.0/26 | 192.168.1.0/26 | 192.168.1.226 | 192.168.1.226/32 + | ::ffff:1.2.3.4/128 | ::ffff:1.2.3.4/128 | ::4.3.2.1/24 | ::/24 + | 10:23::f1/128 | 10:23::f1/128 | 10:23::f1/64 | 10:23::/64 + | 10:23::8000/113 | 10:23::8000/113 | 10:23::ffff | 10:23::ffff/128 +(17 rows) + +SELECT '' AS ten, c AS cidr, masklen(c) AS "masklen(cidr)", + i AS inet, masklen(i) AS "masklen(inet)" FROM INET_TBL ORDER BY i, c; + ten | cidr | masklen(cidr) | inet | masklen(inet) +-----+--------------------+---------------+------------------+--------------- + | 10.0.0.0/8 | 8 | 9.1.2.3/8 | 8 + | 10.0.0.0/8 | 8 | 10.1.2.3/8 | 8 + | 10.0.0.0/8 | 8 | 10.1.2.3/8 | 8 + | 10.0.0.0/32 | 32 | 10.1.2.3/8 | 8 + | 10.1.0.0/16 | 16 | 10.1.2.3/16 | 16 + | 10.1.2.0/24 | 24 | 10.1.2.3/24 | 24 + | 10.1.2.3/32 | 32 | 10.1.2.3 | 32 + | 10.0.0.0/8 | 8 | 11.1.2.3/8 | 8 + | 192.168.1.0/24 | 24 | 192.168.1.0/24 | 24 + | 192.168.1.0/24 | 24 | 192.168.1.226/24 | 24 + | 192.168.1.0/24 | 24 | 192.168.1.255/24 | 24 + | 192.168.1.0/24 | 24 | 192.168.1.0/25 | 25 + | 192.168.1.0/24 | 24 | 192.168.1.255/25 | 25 + | 192.168.1.0/26 | 26 | 192.168.1.226 | 32 + | ::ffff:1.2.3.4/128 | 128 | ::4.3.2.1/24 | 24 + | 10:23::f1/128 | 128 | 10:23::f1/64 | 64 + | 10:23::8000/113 | 113 | 10:23::ffff | 128 +(17 rows) + +SELECT '' AS four, c AS cidr, masklen(c) AS "masklen(cidr)", + i AS inet, masklen(i) AS "masklen(inet)" FROM INET_TBL + WHERE masklen(c) <= 8 ORDER BY i, c; + four | cidr | masklen(cidr) | inet | masklen(inet) +------+------------+---------------+------------+--------------- + | 10.0.0.0/8 | 8 | 9.1.2.3/8 | 8 + | 10.0.0.0/8 | 8 | 10.1.2.3/8 | 8 + | 10.0.0.0/8 | 8 | 10.1.2.3/8 | 8 + | 10.0.0.0/8 | 8 | 11.1.2.3/8 | 8 +(4 rows) + +SELECT '' AS six, c AS cidr, i AS inet FROM INET_TBL + WHERE c = i ORDER BY i, c; + six | cidr | inet +-----+----------------+---------------- + | 10.1.2.3/32 | 10.1.2.3 + | 192.168.1.0/24 | 192.168.1.0/24 +(2 rows) + +SELECT '' AS ten, i, c, + i < c AS lt, i <= c AS le, i = c AS eq, + i >= c AS ge, i > c AS gt, i <> c AS ne, + i << c AS sb, i <<= c AS sbe, + i >> c AS sup, i >>= c AS spe + FROM INET_TBL ORDER BY i, c; + ten | i | c | lt | le | eq | ge | gt | ne | sb | sbe | sup | spe +-----+------------------+--------------------+----+----+----+----+----+----+----+-----+-----+----- + | 9.1.2.3/8 | 10.0.0.0/8 | t | t | f | f | f | t | f | f | f | f + | 10.1.2.3/8 | 10.0.0.0/8 | f | f | f | t | t | t | f | t | f | t + | 10.1.2.3/8 | 10.0.0.0/8 | f | f | f | t | t | t | f | t | f | t + | 10.1.2.3/8 | 10.0.0.0/32 | t | t | f | f | f | t | f | f | t | t + | 10.1.2.3/16 | 10.1.0.0/16 | f | f | f | t | t | t | f | t | f | t + | 10.1.2.3/24 | 10.1.2.0/24 | f | f | f | t | t | t | f | t | f | t + | 10.1.2.3 | 10.1.2.3/32 | f | t | t | t | f | f | f | t | f | t + | 11.1.2.3/8 | 10.0.0.0/8 | f | f | f | t | t | t | f | f | f | f + | 192.168.1.0/24 | 192.168.1.0/24 | f | t | t | t | f | f | f | t | f | t + | 192.168.1.226/24 | 192.168.1.0/24 | f | f | f | t | t | t | f | t | f | t + | 192.168.1.255/24 | 192.168.1.0/24 | f | f | f | t | t | t | f | t | f | t + | 192.168.1.0/25 | 192.168.1.0/24 | f | f | f | t | t | t | t | t | f | f + | 192.168.1.255/25 | 192.168.1.0/24 | f | f | f | t | t | t | t | t | f | f + | 192.168.1.226 | 192.168.1.0/26 | f | f | f | t | t | t | f | f | f | f + | ::4.3.2.1/24 | ::ffff:1.2.3.4/128 | t | t | f | f | f | t | f | f | t | t + | 10:23::f1/64 | 10:23::f1/128 | t | t | f | f | f | t | f | f | t | t + | 10:23::ffff | 10:23::8000/113 | f | f | f | t | t | t | t | t | f | f +(17 rows) + +-- check the conversion to/from text and set_netmask +SELECT '' AS ten, set_masklen(inet(text(i)), 24) FROM INET_TBL ORDER BY i; + ten | set_masklen +-----+------------------ + | 9.1.2.3/24 + | 10.1.2.3/24 + | 10.1.2.3/24 + | 10.1.2.3/24 + | 10.1.2.3/24 + | 10.1.2.3/24 + | 10.1.2.3/24 + | 11.1.2.3/24 + | 192.168.1.0/24 + | 192.168.1.226/24 + | 192.168.1.255/24 + | 192.168.1.0/24 + | 192.168.1.255/24 + | 192.168.1.226/24 + | ::4.3.2.1/24 + | 10:23::f1/24 + | 10:23::ffff/24 +(17 rows) + +-- check that index works correctly +CREATE INDEX inet_idx1 ON inet_tbl(i); +SET enable_seqscan TO off; +SELECT * FROM inet_tbl WHERE i<<'192.168.1.0/24'::cidr ORDER BY i, c; + c | i +----------------+------------------ + 192.168.1.0/24 | 192.168.1.0/25 + 192.168.1.0/24 | 192.168.1.255/25 + 192.168.1.0/26 | 192.168.1.226 +(3 rows) + +SELECT * FROM inet_tbl WHERE i<<='192.168.1.0/24'::cidr ORDER BY i; + c | i +----------------+------------------ + 192.168.1.0/24 | 192.168.1.0/24 + 192.168.1.0/24 | 192.168.1.226/24 + 192.168.1.0/24 | 192.168.1.255/24 + 192.168.1.0/24 | 192.168.1.0/25 + 192.168.1.0/24 | 192.168.1.255/25 + 192.168.1.0/26 | 192.168.1.226 +(6 rows) + +SET enable_seqscan TO on; +DROP INDEX inet_idx1; +-- simple tests of inet boolean and arithmetic operators +SELECT i, ~i AS "~i" FROM inet_tbl ORDER BY i; + i | ~i +------------------+-------------------------------------------- + 9.1.2.3/8 | 246.254.253.252/8 + 10.1.2.3/8 | 245.254.253.252/8 + 10.1.2.3/8 | 245.254.253.252/8 + 10.1.2.3/8 | 245.254.253.252/8 + 10.1.2.3/16 | 245.254.253.252/16 + 10.1.2.3/24 | 245.254.253.252/24 + 10.1.2.3 | 245.254.253.252 + 11.1.2.3/8 | 244.254.253.252/8 + 192.168.1.0/24 | 63.87.254.255/24 + 192.168.1.226/24 | 63.87.254.29/24 + 192.168.1.255/24 | 63.87.254.0/24 + 192.168.1.0/25 | 63.87.254.255/25 + 192.168.1.255/25 | 63.87.254.0/25 + 192.168.1.226 | 63.87.254.29 + ::4.3.2.1/24 | ffff:ffff:ffff:ffff:ffff:ffff:fbfc:fdfe/24 + 10:23::f1/64 | ffef:ffdc:ffff:ffff:ffff:ffff:ffff:ff0e/64 + 10:23::ffff | ffef:ffdc:ffff:ffff:ffff:ffff:ffff:0 +(17 rows) + +SELECT i, c, i & c AS "and" FROM inet_tbl ORDER BY i, c; + i | c | and +------------------+--------------------+---------------- + 9.1.2.3/8 | 10.0.0.0/8 | 8.0.0.0/8 + 10.1.2.3/8 | 10.0.0.0/8 | 10.0.0.0/8 + 10.1.2.3/8 | 10.0.0.0/8 | 10.0.0.0/8 + 10.1.2.3/8 | 10.0.0.0/32 | 10.0.0.0 + 10.1.2.3/16 | 10.1.0.0/16 | 10.1.0.0/16 + 10.1.2.3/24 | 10.1.2.0/24 | 10.1.2.0/24 + 10.1.2.3 | 10.1.2.3/32 | 10.1.2.3 + 11.1.2.3/8 | 10.0.0.0/8 | 10.0.0.0/8 + 192.168.1.0/24 | 192.168.1.0/24 | 192.168.1.0/24 + 192.168.1.226/24 | 192.168.1.0/24 | 192.168.1.0/24 + 192.168.1.255/24 | 192.168.1.0/24 | 192.168.1.0/24 + 192.168.1.0/25 | 192.168.1.0/24 | 192.168.1.0/25 + 192.168.1.255/25 | 192.168.1.0/24 | 192.168.1.0/25 + 192.168.1.226 | 192.168.1.0/26 | 192.168.1.0 + ::4.3.2.1/24 | ::ffff:1.2.3.4/128 | ::0.2.2.0 + 10:23::f1/64 | 10:23::f1/128 | 10:23::f1 + 10:23::ffff | 10:23::8000/113 | 10:23::8000 +(17 rows) + +SELECT i, c, i | c AS "or" FROM inet_tbl ORDER BY i, c; + i | c | or +------------------+--------------------+------------------ + 9.1.2.3/8 | 10.0.0.0/8 | 11.1.2.3/8 + 10.1.2.3/8 | 10.0.0.0/8 | 10.1.2.3/8 + 10.1.2.3/8 | 10.0.0.0/8 | 10.1.2.3/8 + 10.1.2.3/8 | 10.0.0.0/32 | 10.1.2.3 + 10.1.2.3/16 | 10.1.0.0/16 | 10.1.2.3/16 + 10.1.2.3/24 | 10.1.2.0/24 | 10.1.2.3/24 + 10.1.2.3 | 10.1.2.3/32 | 10.1.2.3 + 11.1.2.3/8 | 10.0.0.0/8 | 11.1.2.3/8 + 192.168.1.0/24 | 192.168.1.0/24 | 192.168.1.0/24 + 192.168.1.226/24 | 192.168.1.0/24 | 192.168.1.226/24 + 192.168.1.255/24 | 192.168.1.0/24 | 192.168.1.255/24 + 192.168.1.0/25 | 192.168.1.0/24 | 192.168.1.0/25 + 192.168.1.255/25 | 192.168.1.0/24 | 192.168.1.255/25 + 192.168.1.226 | 192.168.1.0/26 | 192.168.1.226 + ::4.3.2.1/24 | ::ffff:1.2.3.4/128 | ::ffff:5.3.3.5 + 10:23::f1/64 | 10:23::f1/128 | 10:23::f1 + 10:23::ffff | 10:23::8000/113 | 10:23::ffff +(17 rows) + +SELECT i, i + 500 AS "i+500" FROM inet_tbl ORDER BY i; + i | i+500 +------------------+------------------ + 9.1.2.3/8 | 9.1.3.247/8 + 10.1.2.3/8 | 10.1.3.247/8 + 10.1.2.3/8 | 10.1.3.247/8 + 10.1.2.3/8 | 10.1.3.247/8 + 10.1.2.3/16 | 10.1.3.247/16 + 10.1.2.3/24 | 10.1.3.247/24 + 10.1.2.3 | 10.1.3.247 + 11.1.2.3/8 | 11.1.3.247/8 + 192.168.1.0/24 | 192.168.2.244/24 + 192.168.1.226/24 | 192.168.3.214/24 + 192.168.1.255/24 | 192.168.3.243/24 + 192.168.1.0/25 | 192.168.2.244/25 + 192.168.1.255/25 | 192.168.3.243/25 + 192.168.1.226 | 192.168.3.214 + ::4.3.2.1/24 | ::4.3.3.245/24 + 10:23::f1/64 | 10:23::2e5/64 + 10:23::ffff | 10:23::1:1f3 +(17 rows) + +SELECT i, i - 500 AS "i-500" FROM inet_tbl ORDER BY i; + i | i-500 +------------------+---------------------------------------- + 9.1.2.3/8 | 9.1.0.15/8 + 10.1.2.3/8 | 10.1.0.15/8 + 10.1.2.3/8 | 10.1.0.15/8 + 10.1.2.3/8 | 10.1.0.15/8 + 10.1.2.3/16 | 10.1.0.15/16 + 10.1.2.3/24 | 10.1.0.15/24 + 10.1.2.3 | 10.1.0.15 + 11.1.2.3/8 | 11.1.0.15/8 + 192.168.1.0/24 | 192.167.255.12/24 + 192.168.1.226/24 | 192.167.255.238/24 + 192.168.1.255/24 | 192.168.0.11/24 + 192.168.1.0/25 | 192.167.255.12/25 + 192.168.1.255/25 | 192.168.0.11/25 + 192.168.1.226 | 192.167.255.238 + ::4.3.2.1/24 | ::4.3.0.13/24 + 10:23::f1/64 | 10:22:ffff:ffff:ffff:ffff:ffff:fefd/64 + 10:23::ffff | 10:23::fe0b +(17 rows) + +SELECT i, c, i - c AS "minus" FROM inet_tbl ORDER BY i, c; + i | c | minus +------------------+--------------------+------------------ + 9.1.2.3/8 | 10.0.0.0/8 | -16711165 + 10.1.2.3/8 | 10.0.0.0/8 | 66051 + 10.1.2.3/8 | 10.0.0.0/8 | 66051 + 10.1.2.3/8 | 10.0.0.0/32 | 66051 + 10.1.2.3/16 | 10.1.0.0/16 | 515 + 10.1.2.3/24 | 10.1.2.0/24 | 3 + 10.1.2.3 | 10.1.2.3/32 | 0 + 11.1.2.3/8 | 10.0.0.0/8 | 16843267 + 192.168.1.0/24 | 192.168.1.0/24 | 0 + 192.168.1.226/24 | 192.168.1.0/24 | 226 + 192.168.1.255/24 | 192.168.1.0/24 | 255 + 192.168.1.0/25 | 192.168.1.0/24 | 0 + 192.168.1.255/25 | 192.168.1.0/24 | 255 + 192.168.1.226 | 192.168.1.0/26 | 226 + ::4.3.2.1/24 | ::ffff:1.2.3.4/128 | -281470631346435 + 10:23::f1/64 | 10:23::f1/128 | 0 + 10:23::ffff | 10:23::8000/113 | 32767 +(17 rows) + +SELECT '127.0.0.1'::inet + 257; + ?column? +----------- + 127.0.1.2 +(1 row) + +SELECT ('127.0.0.1'::inet + 257) - 257; + ?column? +----------- + 127.0.0.1 +(1 row) + +SELECT '127::1'::inet + 257; + ?column? +---------- + 127::102 +(1 row) + +SELECT ('127::1'::inet + 257) - 257; + ?column? +---------- + 127::1 +(1 row) + +SELECT '127.0.0.2'::inet - ('127.0.0.2'::inet + 500); + ?column? +---------- + -500 +(1 row) + +SELECT '127.0.0.2'::inet - ('127.0.0.2'::inet - 500); + ?column? +---------- + 500 +(1 row) + +SELECT '127::2'::inet - ('127::2'::inet + 500); + ?column? +---------- + -500 +(1 row) + +SELECT '127::2'::inet - ('127::2'::inet - 500); + ?column? +---------- + 500 +(1 row) + +-- these should give overflow errors: +SELECT '127.0.0.1'::inet + 10000000000; +ERROR: result is out of range +SELECT '127.0.0.1'::inet - 10000000000; +ERROR: result is out of range +SELECT '126::1'::inet - '127::2'::inet; +ERROR: result is out of range +SELECT '127::1'::inet - '126::2'::inet; +ERROR: result is out of range +-- but not these +SELECT '127::1'::inet + 10000000000; + ?column? +------------------ + 127::2:540b:e401 +(1 row) + +SELECT '127::1'::inet - '127::2'::inet; + ?column? +---------- + -1 +(1 row) + diff --git a/src/test/regress/sql/inet.sql b/src/test/regress/sql/inet.sql index 7ba1080..024c917 100644 --- a/src/test/regress/sql/inet.sql +++ b/src/test/regress/sql/inet.sql @@ -29,7 +29,7 @@ INSERT INTO INET_TBL (c, i) VALUES ('1234::1234::1234', '::1.2.3.4'); -- check that CIDR rejects invalid input when converting from text: INSERT INTO INET_TBL (c, i) VALUES (cidr('192.168.1.2/30'), '192.168.1.226'); INSERT INTO INET_TBL (c, i) VALUES (cidr('ffff:ffff:ffff:ffff::/24'), '::192.168.1.226'); -SELECT '' AS ten, c AS cidr, i AS inet FROM INET_TBL; +SELECT '' AS ten, c AS cidr, i AS inet FROM INET_TBL ORDER BY cidr; -- now test some support functions ----------------------------------------------------------------------- Summary of changes: src/test/regress/expected/{inet.out => inet_1.out} | 26 ++++++++++---------- src/test/regress/sql/inet.sql | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) copy src/test/regress/expected/{inet.out => inet_1.out} (99%) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-09 07:02:32
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via d6beeda6a68cce6f74d179e3520443be2a29bb4d (commit) from fe063aa6a39f12ce33d546f6a0730c67bee9bee8 (commit) - Log ----------------------------------------------------------------- commit d6beeda6a68cce6f74d179e3520443be2a29bb4d Author: Michael P <mic...@us...> Date: Wed Mar 9 16:01:05 2011 +0900 Fix for regression test returning TEMP tables are not supported so this test has to return error messages in consequence. diff --git a/src/test/regress/expected/returning_1.out b/src/test/regress/expected/returning_1.out new file mode 100644 index 0000000..42be497 --- /dev/null +++ b/src/test/regress/expected/returning_1.out @@ -0,0 +1,265 @@ +-- +-- Test INSERT/UPDATE/DELETE RETURNING +-- +-- Simple cases +CREATE TEMP TABLE foo (f1 serial, f2 text, f3 int default 42); +NOTICE: CREATE TABLE will create implicit sequence "foo_f1_seq" for serial column "foo.f1" +ERROR: PG-XC does not yet support temporary tables +INSERT INTO foo (f2,f3) + VALUES ('test', DEFAULT), ('More', 11), (upper('more'), 7+9) + RETURNING *, f1+f3 AS sum; +ERROR: relation "foo" does not exist +LINE 1: INSERT INTO foo (f2,f3) + ^ +SELECT * FROM foo ORDER BY f1; +ERROR: relation "foo" does not exist +LINE 1: SELECT * FROM foo ORDER BY f1; + ^ +UPDATE foo SET f2 = lower(f2), f3 = DEFAULT RETURNING foo.*, f1+f3 AS sum13; +ERROR: relation "foo" does not exist +LINE 1: UPDATE foo SET f2 = lower(f2), f3 = DEFAULT RETURNING foo.*,... + ^ +SELECT * FROM foo ORDER BY f1; +ERROR: relation "foo" does not exist +LINE 1: SELECT * FROM foo ORDER BY f1; + ^ +DELETE FROM foo WHERE f1 > 2 RETURNING f3, f2, f1, least(f1,f3); +ERROR: relation "foo" does not exist +LINE 1: DELETE FROM foo WHERE f1 > 2 RETURNING f3, f2, f1, least(f1,... + ^ +SELECT * FROM foo ORDER BY f1; +ERROR: relation "foo" does not exist +LINE 1: SELECT * FROM foo ORDER BY f1; + ^ +-- Subplans and initplans in the RETURNING list +INSERT INTO foo SELECT f1+10, f2, f3+99 FROM foo + RETURNING *, f1+112 IN (SELECT q1 FROM int8_tbl) AS subplan, + EXISTS(SELECT * FROM int4_tbl) AS initplan; +ERROR: relation "foo" does not exist +LINE 1: INSERT INTO foo SELECT f1+10, f2, f3+99 FROM foo + ^ +UPDATE foo SET f3 = f3 * 2 + WHERE f1 > 10 + RETURNING *, f1+112 IN (SELECT q1 FROM int8_tbl) AS subplan, + EXISTS(SELECT * FROM int4_tbl) AS initplan; +ERROR: relation "foo" does not exist +LINE 1: UPDATE foo SET f3 = f3 * 2 + ^ +DELETE FROM foo + WHERE f1 > 10 + RETURNING *, f1+112 IN (SELECT q1 FROM int8_tbl) AS subplan, + EXISTS(SELECT * FROM int4_tbl) AS initplan; +ERROR: relation "foo" does not exist +LINE 1: DELETE FROM foo + ^ +-- Joins +UPDATE foo SET f3 = f3*2 + FROM int4_tbl i + WHERE foo.f1 + 123455 = i.f1 + RETURNING foo.*, i.f1 as "i.f1"; +ERROR: relation "foo" does not exist +LINE 1: UPDATE foo SET f3 = f3*2 + ^ +SELECT * FROM foo ORDER BY f1; +ERROR: relation "foo" does not exist +LINE 1: SELECT * FROM foo ORDER BY f1; + ^ +DELETE FROM foo + USING int4_tbl i + WHERE foo.f1 + 123455 = i.f1 + RETURNING foo.*, i.f1 as "i.f1"; +ERROR: relation "foo" does not exist +LINE 1: DELETE FROM foo + ^ +SELECT * FROM foo ORDER BY f1; +ERROR: relation "foo" does not exist +LINE 1: SELECT * FROM foo ORDER BY f1; + ^ +-- Check inheritance cases +CREATE TEMP TABLE foochild (fc int) INHERITS (foo); +ERROR: PG-XC does not yet support temporary tables +INSERT INTO foochild VALUES(123,'child',999,-123); +ERROR: relation "foochild" does not exist +LINE 1: INSERT INTO foochild VALUES(123,'child',999,-123); + ^ +ALTER TABLE foo ADD COLUMN f4 int8 DEFAULT 99; +ERROR: relation "foo" does not exist +SELECT * FROM foo ORDER BY f1; +ERROR: relation "foo" does not exist +LINE 1: SELECT * FROM foo ORDER BY f1; + ^ +SELECT * FROM foochild ORDER BY f1; +ERROR: relation "foochild" does not exist +LINE 1: SELECT * FROM foochild ORDER BY f1; + ^ +UPDATE foo SET f4 = f4 + f3 WHERE f4 = 99 RETURNING *; +ERROR: relation "foo" does not exist +LINE 1: UPDATE foo SET f4 = f4 + f3 WHERE f4 = 99 RETURNING *; + ^ +SELECT * FROM foo ORDER BY f1; +ERROR: relation "foo" does not exist +LINE 1: SELECT * FROM foo ORDER BY f1; + ^ +SELECT * FROM foochild ORDER BY f1; +ERROR: relation "foochild" does not exist +LINE 1: SELECT * FROM foochild ORDER BY f1; + ^ +UPDATE foo SET f3 = f3*2 + FROM int8_tbl i + WHERE foo.f1 = i.q2 + RETURNING *; +ERROR: relation "foo" does not exist +LINE 1: UPDATE foo SET f3 = f3*2 + ^ +SELECT * FROM foo ORDER BY f1; +ERROR: relation "foo" does not exist +LINE 1: SELECT * FROM foo ORDER BY f1; + ^ +SELECT * FROM foochild ORDER BY f1; +ERROR: relation "foochild" does not exist +LINE 1: SELECT * FROM foochild ORDER BY f1; + ^ +DELETE FROM foo + USING int8_tbl i + WHERE foo.f1 = i.q2 + RETURNING *; +ERROR: relation "foo" does not exist +LINE 1: DELETE FROM foo + ^ +SELECT * FROM foo ORDER BY f1; +ERROR: relation "foo" does not exist +LINE 1: SELECT * FROM foo ORDER BY f1; + ^ +SELECT * FROM foochild ORDER BY f1; +ERROR: relation "foochild" does not exist +LINE 1: SELECT * FROM foochild ORDER BY f1; + ^ +DROP TABLE foochild; +ERROR: table "foochild" does not exist +-- Rules and views +CREATE TEMP VIEW voo AS SELECT f1, f2 FROM foo; +ERROR: relation "foo" does not exist +LINE 1: CREATE TEMP VIEW voo AS SELECT f1, f2 FROM foo; + ^ +CREATE RULE voo_i AS ON INSERT TO voo DO INSTEAD + INSERT INTO foo VALUES(new.*, 57); +ERROR: relation "voo" does not exist +INSERT INTO voo VALUES(11,'zit'); +ERROR: relation "voo" does not exist +LINE 1: INSERT INTO voo VALUES(11,'zit'); + ^ +-- fails: +INSERT INTO voo VALUES(12,'zoo') RETURNING *, f1*2; +ERROR: relation "voo" does not exist +LINE 1: INSERT INTO voo VALUES(12,'zoo') RETURNING *, f1*2; + ^ +-- fails, incompatible list: +CREATE OR REPLACE RULE voo_i AS ON INSERT TO voo DO INSTEAD + INSERT INTO foo VALUES(new.*, 57) RETURNING *; +ERROR: relation "voo" does not exist +CREATE OR REPLACE RULE voo_i AS ON INSERT TO voo DO INSTEAD + INSERT INTO foo VALUES(new.*, 57) RETURNING f1, f2; +ERROR: relation "voo" does not exist +-- should still work +INSERT INTO voo VALUES(13,'zit2'); +ERROR: relation "voo" does not exist +LINE 1: INSERT INTO voo VALUES(13,'zit2'); + ^ +-- works now +INSERT INTO voo VALUES(14,'zoo2') RETURNING *; +ERROR: relation "voo" does not exist +LINE 1: INSERT INTO voo VALUES(14,'zoo2') RETURNING *; + ^ +SELECT * FROM foo ORDER BY f1; +ERROR: relation "foo" does not exist +LINE 1: SELECT * FROM foo ORDER BY f1; + ^ +SELECT * FROM voo ORDER BY f1; +ERROR: relation "voo" does not exist +LINE 1: SELECT * FROM voo ORDER BY f1; + ^ +CREATE OR REPLACE RULE voo_u AS ON UPDATE TO voo DO INSTEAD + UPDATE foo SET f1 = new.f1, f2 = new.f2 WHERE f1 = old.f1 + RETURNING f1, f2; +ERROR: relation "voo" does not exist +update voo set f1 = f1 + 1 where f2 = 'zoo2'; +ERROR: relation "voo" does not exist +LINE 1: update voo set f1 = f1 + 1 where f2 = 'zoo2'; + ^ +update voo set f1 = f1 + 1 where f2 = 'zoo2' RETURNING *, f1*2; +ERROR: relation "voo" does not exist +LINE 1: update voo set f1 = f1 + 1 where f2 = 'zoo2' RETURNING *, f1... + ^ +SELECT * FROM foo ORDER BY f1; +ERROR: relation "foo" does not exist +LINE 1: SELECT * FROM foo ORDER BY f1; + ^ +SELECT * FROM voo ORDER BY f1; +ERROR: relation "voo" does not exist +LINE 1: SELECT * FROM voo ORDER BY f1; + ^ +CREATE OR REPLACE RULE voo_d AS ON DELETE TO voo DO INSTEAD + DELETE FROM foo WHERE f1 = old.f1 + RETURNING f1, f2; +ERROR: relation "voo" does not exist +DELETE FROM foo WHERE f1 = 13; +ERROR: relation "foo" does not exist +LINE 1: DELETE FROM foo WHERE f1 = 13; + ^ +DELETE FROM foo WHERE f2 = 'zit' RETURNING *; +ERROR: relation "foo" does not exist +LINE 1: DELETE FROM foo WHERE f2 = 'zit' RETURNING *; + ^ +SELECT * FROM foo ORDER BY f1; +ERROR: relation "foo" does not exist +LINE 1: SELECT * FROM foo ORDER BY f1; + ^ +SELECT * FROM voo ORDER BY f1; +ERROR: relation "voo" does not exist +LINE 1: SELECT * FROM voo ORDER BY f1; + ^ +-- Try a join case +CREATE TEMP TABLE joinme (f2j text, other int); +ERROR: PG-XC does not yet support temporary tables +INSERT INTO joinme VALUES('more', 12345); +ERROR: relation "joinme" does not exist +LINE 1: INSERT INTO joinme VALUES('more', 12345); + ^ +INSERT INTO joinme VALUES('zoo2', 54321); +ERROR: relation "joinme" does not exist +LINE 1: INSERT INTO joinme VALUES('zoo2', 54321); + ^ +INSERT INTO joinme VALUES('other', 0); +ERROR: relation "joinme" does not exist +LINE 1: INSERT INTO joinme VALUES('other', 0); + ^ +CREATE TEMP VIEW joinview AS + SELECT foo.*, other FROM foo JOIN joinme ON (f2 = f2j); +ERROR: relation "foo" does not exist +LINE 2: SELECT foo.*, other FROM foo JOIN joinme ON (f2 = f2j); + ^ +SELECT * FROM joinview ORDER BY f1; +ERROR: relation "joinview" does not exist +LINE 1: SELECT * FROM joinview ORDER BY f1; + ^ +CREATE RULE joinview_u AS ON UPDATE TO joinview DO INSTEAD + UPDATE foo SET f1 = new.f1, f3 = new.f3 + FROM joinme WHERE f2 = f2j AND f2 = old.f2 + RETURNING foo.*, other; +ERROR: relation "joinview" does not exist +UPDATE joinview SET f1 = f1 + 1 WHERE f3 = 57 RETURNING *, other + 1; +ERROR: relation "joinview" does not exist +LINE 1: UPDATE joinview SET f1 = f1 + 1 WHERE f3 = 57 RETURNING *, o... + ^ +SELECT * FROM joinview ORDER BY f1; +ERROR: relation "joinview" does not exist +LINE 1: SELECT * FROM joinview ORDER BY f1; + ^ +SELECT * FROM foo ORDER BY f1; +ERROR: relation "foo" does not exist +LINE 1: SELECT * FROM foo ORDER BY f1; + ^ +SELECT * FROM voo ORDER BY f1; +ERROR: relation "voo" does not exist +LINE 1: SELECT * FROM voo ORDER BY f1; + ^ ----------------------------------------------------------------------- Summary of changes: src/test/regress/expected/returning_1.out | 265 +++++++++++++++++++++++++++++ 1 files changed, 265 insertions(+), 0 deletions(-) create mode 100644 src/test/regress/expected/returning_1.out hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-09 06:47:26
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via fe063aa6a39f12ce33d546f6a0730c67bee9bee8 (commit) from 6683a32a11ff2380ec743db49a52bc297acd14cb (commit) - Log ----------------------------------------------------------------- commit fe063aa6a39f12ce33d546f6a0730c67bee9bee8 Author: Michael P <mic...@us...> Date: Wed Mar 9 15:46:08 2011 +0900 Fix for regression test create_table A couple of NOTICE messages were missing diff --git a/src/test/regress/expected/create_table_1.out b/src/test/regress/expected/create_table_1.out index 76a1b71..6728a0c 100644 --- a/src/test/regress/expected/create_table_1.out +++ b/src/test/regress/expected/create_table_1.out @@ -81,15 +81,15 @@ CREATE TABLE student ( CREATE TABLE stud_emp ( percent int4 ) INHERITS (emp, student); +NOTICE: merging multiple inherited definitions of column "name" +NOTICE: merging multiple inherited definitions of column "age" +NOTICE: merging multiple inherited definitions of column "location" ERROR: Cannot currently distribute a table with more than one parent. CREATE TABLE city ( name name, location box, budget city_budget ); -ERROR: type "city_budget" does not exist -LINE 4: budget city_budget - ^ CREATE TABLE dept ( dname name, mgrname text @@ -136,6 +136,8 @@ CREATE TABLE c_star ( CREATE TABLE d_star ( d float8 ) INHERITS (b_star, c_star); +NOTICE: merging multiple inherited definitions of column "class" +NOTICE: merging multiple inherited definitions of column "a" ERROR: Cannot currently distribute a table with more than one parent. CREATE TABLE e_star ( e int2 ----------------------------------------------------------------------- Summary of changes: src/test/regress/expected/create_table_1.out | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-09 04:33:21
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 6683a32a11ff2380ec743db49a52bc297acd14cb (commit) from aadbdfe18024455d5e18cf9007de5b8a3f5135dc (commit) - Log ----------------------------------------------------------------- commit 6683a32a11ff2380ec743db49a52bc297acd14cb Author: Michael P <mic...@us...> Date: Wed Mar 9 13:30:50 2011 +0900 Cleanup of regression files Some files that have been autogenerated by pg_regress have been kept in repository diff --git a/src/test/regress/expected/constraints.out b/src/test/regress/expected/constraints.out deleted file mode 100644 index d7a988a..0000000 --- a/src/test/regress/expected/constraints.out +++ /dev/null @@ -1,377 +0,0 @@ --- --- CONSTRAINTS --- Constraints can be specified with: --- - DEFAULT clause --- - CHECK clauses --- - PRIMARY KEY clauses --- - UNIQUE clauses --- --- --- DEFAULT syntax --- -CREATE TABLE DEFAULT_TBL (i int DEFAULT 100, - x text DEFAULT 'vadim', f float8 DEFAULT 123.456); -INSERT INTO DEFAULT_TBL VALUES (1, 'thomas', 57.0613); -INSERT INTO DEFAULT_TBL VALUES (1, 'bruce'); -INSERT INTO DEFAULT_TBL (i, f) VALUES (2, 987.654); -INSERT INTO DEFAULT_TBL (x) VALUES ('marc'); -INSERT INTO DEFAULT_TBL VALUES (3, null, 1.0); -SELECT '' AS five, * FROM DEFAULT_TBL ORDER BY i,x,f; - five | i | x | f -------+-----+--------+--------- - | 1 | bruce | 123.456 - | 1 | thomas | 57.0613 - | 2 | vadim | 987.654 - | 3 | | 1 - | 100 | marc | 123.456 -(5 rows) - -CREATE SEQUENCE DEFAULT_SEQ; -CREATE TABLE DEFAULTEXPR_TBL (i1 int DEFAULT 100 + (200-199) * 2, - i2 int DEFAULT nextval('default_seq')); -INSERT INTO DEFAULTEXPR_TBL VALUES (-1, -2); -INSERT INTO DEFAULTEXPR_TBL (i1) VALUES (-3); -INSERT INTO DEFAULTEXPR_TBL (i2) VALUES (-4); -INSERT INTO DEFAULTEXPR_TBL (i2) VALUES (NULL); -SELECT '' AS four, * FROM DEFAULTEXPR_TBL ORDER BY i1,i2; - four | i1 | i2 -------+-----+---- - | -3 | 1 - | -1 | -2 - | 102 | -4 - | 102 | -(4 rows) - --- syntax errors --- test for extraneous comma -CREATE TABLE error_tbl (i int DEFAULT (100, )); -ERROR: syntax error at or near ")" -LINE 1: CREATE TABLE error_tbl (i int DEFAULT (100, )); - ^ --- this will fail because gram.y uses b_expr not a_expr for defaults, --- to avoid a shift/reduce conflict that arises from NOT NULL being --- part of the column definition syntax: -CREATE TABLE error_tbl (b1 bool DEFAULT 1 IN (1, 2)); -ERROR: syntax error at or near "IN" -LINE 1: CREATE TABLE error_tbl (b1 bool DEFAULT 1 IN (1, 2)); - ^ --- this should work, however: -CREATE TABLE error_tbl (b1 bool DEFAULT (1 IN (1, 2))); -DROP TABLE error_tbl; --- --- CHECK syntax --- -CREATE TABLE CHECK_TBL (x int, - CONSTRAINT CHECK_CON CHECK (x > 3)); -INSERT INTO CHECK_TBL VALUES (5); -INSERT INTO CHECK_TBL VALUES (4); -INSERT INTO CHECK_TBL VALUES (3); -ERROR: new row for relation "check_tbl" violates check constraint "check_con" -INSERT INTO CHECK_TBL VALUES (2); -ERROR: new row for relation "check_tbl" violates check constraint "check_con" -INSERT INTO CHECK_TBL VALUES (6); -INSERT INTO CHECK_TBL VALUES (1); -ERROR: new row for relation "check_tbl" violates check constraint "check_con" -SELECT '' AS three, * FROM CHECK_TBL ORDER BY x; - three | x --------+--- - | 4 - | 5 - | 6 -(3 rows) - -CREATE SEQUENCE CHECK_SEQ; -CREATE TABLE CHECK2_TBL (x int, y text, z int, - CONSTRAINT SEQUENCE_CON - CHECK (x > 3 and y <> 'check failed' and z < 8)); -INSERT INTO CHECK2_TBL VALUES (4, 'check ok', -2); -INSERT INTO CHECK2_TBL VALUES (1, 'x check failed', -2); -ERROR: new row for relation "check2_tbl" violates check constraint "sequence_con" -INSERT INTO CHECK2_TBL VALUES (5, 'z check failed', 10); -ERROR: new row for relation "check2_tbl" violates check constraint "sequence_con" -INSERT INTO CHECK2_TBL VALUES (0, 'check failed', -2); -ERROR: new row for relation "check2_tbl" violates check constraint "sequence_con" -INSERT INTO CHECK2_TBL VALUES (6, 'check failed', 11); -ERROR: new row for relation "check2_tbl" violates check constraint "sequence_con" -INSERT INTO CHECK2_TBL VALUES (7, 'check ok', 7); -SELECT '' AS two, * from CHECK2_TBL ORDER BY x,y,z; - two | x | y | z ------+---+----------+---- - | 4 | check ok | -2 - | 7 | check ok | 7 -(2 rows) - --- --- Check constraints on INSERT --- -CREATE SEQUENCE INSERT_SEQ; -CREATE TABLE INSERT_TBL (x INT DEFAULT nextval('insert_seq'), - y TEXT DEFAULT '-NULL-', - z INT DEFAULT -1 * currval('insert_seq'), - CONSTRAINT INSERT_CON CHECK (x >= 3 AND y <> 'check failed' AND x < 8), - CHECK (x + z = 0)); -INSERT INTO INSERT_TBL(x,z) VALUES (2, -2); -ERROR: new row for relation "insert_tbl" violates check constraint "insert_con" -SELECT '' AS zero, * FROM INSERT_TBL order by x,y,z; - zero | x | y | z -------+---+---+--- -(0 rows) - -SELECT 'one' AS one, nextval('insert_seq'); - one | nextval ------+--------- - one | 1 -(1 row) - -INSERT INTO INSERT_TBL(y) VALUES ('Y'); -ERROR: new row for relation "insert_tbl" violates check constraint "insert_con" -INSERT INTO INSERT_TBL(y) VALUES ('Y'); -INSERT INTO INSERT_TBL(x,z) VALUES (1, -2); -ERROR: new row for relation "insert_tbl" violates check constraint "insert_tbl_check" -INSERT INTO INSERT_TBL(z,x) VALUES (-7, 7); -INSERT INTO INSERT_TBL VALUES (5, 'check failed', -5); -ERROR: new row for relation "insert_tbl" violates check constraint "insert_con" -INSERT INTO INSERT_TBL VALUES (7, '!check failed', -7); -INSERT INTO INSERT_TBL(y) VALUES ('-!NULL-'); -SELECT '' AS four, * FROM INSERT_TBL order by x,y,z; - four | x | y | z -------+---+---------------+---- - | 3 | Y | -3 - | 4 | -!NULL- | -4 - | 7 | !check failed | -7 - | 7 | -NULL- | -7 -(4 rows) - -INSERT INTO INSERT_TBL(y,z) VALUES ('check failed', 4); -ERROR: new row for relation "insert_tbl" violates check constraint "insert_tbl_check" -INSERT INTO INSERT_TBL(x,y) VALUES (5, 'check failed'); -ERROR: new row for relation "insert_tbl" violates check constraint "insert_con" -INSERT INTO INSERT_TBL(x,y) VALUES (5, '!check failed'); -INSERT INTO INSERT_TBL(y) VALUES ('-!NULL-'); -SELECT '' AS six, * FROM INSERT_TBL order by x,y,z; - six | x | y | z ------+---+---------------+---- - | 3 | Y | -3 - | 4 | -!NULL- | -4 - | 5 | !check failed | -5 - | 6 | -!NULL- | -6 - | 7 | !check failed | -7 - | 7 | -NULL- | -7 -(6 rows) - -SELECT 'seven' AS one, nextval('insert_seq'); - one | nextval --------+--------- - seven | 7 -(1 row) - -INSERT INTO INSERT_TBL(y) VALUES ('Y'); -ERROR: new row for relation "insert_tbl" violates check constraint "insert_con" -SELECT 'eight' AS one, currval('insert_seq'); - one | currval --------+--------- - eight | 8 -(1 row) - --- According to SQL92, it is OK to insert a record that gives rise to NULL --- constraint-condition results. Postgres used to reject this, but it --- was wrong: -INSERT INTO INSERT_TBL VALUES (null, null, null); -SELECT '' AS nine, * FROM INSERT_TBL order by x,y,z; - nine | x | y | z -------+---+---------------+---- - | 3 | Y | -3 - | 4 | -!NULL- | -4 - | 5 | !check failed | -5 - | 6 | -!NULL- | -6 - | 7 | !check failed | -7 - | 7 | -NULL- | -7 - | | | -(7 rows) - --- --- Check inheritance of defaults and constraints --- -CREATE TABLE INSERT_CHILD (cx INT default 42, - cy INT CHECK (cy > x)) - INHERITS (INSERT_TBL); -INSERT INTO INSERT_CHILD(x,z,cy) VALUES (7,-7,11); -INSERT INTO INSERT_CHILD(x,z,cy) VALUES (7,-7,6); -ERROR: new row for relation "insert_child" violates check constraint "insert_child_check" -INSERT INTO INSERT_CHILD(x,z,cy) VALUES (6,-7,7); -ERROR: new row for relation "insert_child" violates check constraint "insert_tbl_check" -INSERT INTO INSERT_CHILD(x,y,z,cy) VALUES (6,'check failed',-6,7); -ERROR: new row for relation "insert_child" violates check constraint "insert_con" -SELECT * FROM INSERT_CHILD order by 1,2,3; - x | y | z | cx | cy ----+--------+----+----+---- - 7 | -NULL- | -7 | 42 | 11 -(1 row) - -DROP TABLE INSERT_CHILD; --- --- Check constraints on INSERT INTO --- -DELETE FROM INSERT_TBL; -ALTER SEQUENCE INSERT_SEQ RESTART WITH 4; -CREATE TABLE tmp (xd INT, yd TEXT, zd INT); -INSERT INTO tmp VALUES (null, 'Y', null); -INSERT INTO tmp VALUES (5, '!check failed', null); -INSERT INTO tmp VALUES (null, 'try again', null); -INSERT INTO INSERT_TBL(y) select yd from tmp; -SELECT '' AS three, * FROM INSERT_TBL order by x,y,z; - three | x | y | z --------+---+---------------+---- - | 4 | Y | -4 - | 5 | !check failed | -5 - | 6 | try again | -6 -(3 rows) - -INSERT INTO INSERT_TBL SELECT * FROM tmp WHERE yd = 'try again'; -INSERT INTO INSERT_TBL(y,z) SELECT yd, -7 FROM tmp WHERE yd = 'try again'; -INSERT INTO INSERT_TBL(y,z) SELECT yd, -8 FROM tmp WHERE yd = 'try again'; -ERROR: new row for relation "insert_tbl" violates check constraint "insert_con" -SELECT '' AS four, * FROM INSERT_TBL order by x,y,z; - four | x | y | z -------+---+---------------+---- - | 4 | Y | -4 - | 5 | !check failed | -5 - | 6 | try again | -6 - | 7 | try again | -7 - | | try again | -(5 rows) - -DROP TABLE tmp; --- --- Check constraints on UPDATE --- -UPDATE INSERT_TBL SET x = NULL WHERE x = 5; -UPDATE INSERT_TBL SET x = 6 WHERE x = 6; -UPDATE INSERT_TBL SET x = -z, z = -x; -UPDATE INSERT_TBL SET x = z, z = x; -ERROR: new row for relation "insert_tbl" violates check constraint "insert_con" -SELECT * FROM INSERT_TBL order by x,y,z; - x | y | z ----+---------------+---- - 4 | Y | -4 - 5 | !check failed | - 6 | try again | -6 - 7 | try again | -7 - | try again | -(5 rows) - --- DROP TABLE INSERT_TBL; --- --- Check constraints on COPY FROM --- -CREATE TABLE COPY_TBL (x INT, y TEXT, z INT, - CONSTRAINT COPY_CON - CHECK (x > 3 AND y <> 'check failed' AND x < 7 )); -COPY COPY_TBL FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/constro.data'; -SELECT '' AS two, * FROM COPY_TBL order by x,y,z; - two | x | y | z ------+---+---------------+--- - | 4 | !check failed | 5 - | 6 | OK | 4 -(2 rows) - -COPY COPY_TBL FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/constrf.data'; -ERROR: new row for relation "copy_tbl" violates check constraint "copy_con" -CONTEXT: COPY copy_tbl, line 2: "7 check failed 6" -SELECT * FROM COPY_TBL order by x,y,z; - x | y | z ----+---------------+--- - 4 | !check failed | 5 - 6 | OK | 4 -(2 rows) - --- --- Primary keys --- -CREATE TABLE PRIMARY_TBL (i int PRIMARY KEY, t text); -NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "primary_tbl_pkey" for table "primary_tbl" -INSERT INTO PRIMARY_TBL VALUES (1, 'one'); -INSERT INTO PRIMARY_TBL VALUES (2, 'two'); -INSERT INTO PRIMARY_TBL VALUES (1, 'three'); -ERROR: duplicate key value violates unique constraint "primary_tbl_pkey" -INSERT INTO PRIMARY_TBL VALUES (4, 'three'); -INSERT INTO PRIMARY_TBL VALUES (5, 'one'); -INSERT INTO PRIMARY_TBL (t) VALUES ('six'); -ERROR: null value in column "i" violates not-null constraint -SELECT '' AS four, * FROM PRIMARY_TBL order by i,t; - four | i | t -------+---+------- - | 1 | one - | 2 | two - | 4 | three - | 5 | one -(4 rows) - -DROP TABLE PRIMARY_TBL; -CREATE TABLE PRIMARY_TBL (i int, t text, - PRIMARY KEY(i,t)); -NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "primary_tbl_pkey" for table "primary_tbl" -INSERT INTO PRIMARY_TBL VALUES (1, 'one'); -INSERT INTO PRIMARY_TBL VALUES (2, 'two'); -INSERT INTO PRIMARY_TBL VALUES (1, 'three'); -INSERT INTO PRIMARY_TBL VALUES (4, 'three'); -INSERT INTO PRIMARY_TBL VALUES (5, 'one'); -INSERT INTO PRIMARY_TBL (t) VALUES ('six'); -ERROR: null value in column "i" violates not-null constraint -SELECT '' AS three, * FROM PRIMARY_TBL order by i,t; - three | i | t --------+---+------- - | 1 | one - | 1 | three - | 2 | two - | 4 | three - | 5 | one -(5 rows) - -DROP TABLE PRIMARY_TBL; --- --- Unique keys --- -CREATE TABLE UNIQUE_TBL (i int UNIQUE, t text); -NOTICE: CREATE TABLE / UNIQUE will create implicit index "unique_tbl_i_key" for table "unique_tbl" -INSERT INTO UNIQUE_TBL VALUES (1, 'one'); -INSERT INTO UNIQUE_TBL VALUES (2, 'two'); -INSERT INTO UNIQUE_TBL VALUES (1, 'three'); -ERROR: duplicate key value violates unique constraint "unique_tbl_i_key" -INSERT INTO UNIQUE_TBL VALUES (4, 'four'); -INSERT INTO UNIQUE_TBL VALUES (5, 'one'); -INSERT INTO UNIQUE_TBL (t) VALUES ('six'); -INSERT INTO UNIQUE_TBL (t) VALUES ('seven'); -SELECT '' AS five, * FROM UNIQUE_TBL order by i,t; - five | i | t -------+---+------- - | 1 | one - | 2 | two - | 4 | four - | 5 | one - | | seven - | | six -(6 rows) - -DROP TABLE UNIQUE_TBL; -CREATE TABLE UNIQUE_TBL (i int, t text, - UNIQUE(i,t)); -NOTICE: CREATE TABLE / UNIQUE will create implicit index "unique_tbl_i_key" for table "unique_tbl" -INSERT INTO UNIQUE_TBL VALUES (1, 'one'); -INSERT INTO UNIQUE_TBL VALUES (2, 'two'); -INSERT INTO UNIQUE_TBL VALUES (1, 'three'); -INSERT INTO UNIQUE_TBL VALUES (1, 'one'); -ERROR: duplicate key value violates unique constraint "unique_tbl_i_key" -INSERT INTO UNIQUE_TBL VALUES (5, 'one'); -INSERT INTO UNIQUE_TBL (t) VALUES ('six'); -SELECT '' AS five, * FROM UNIQUE_TBL order by i,t; - five | i | t -------+---+------- - | 1 | one - | 1 | three - | 2 | two - | 5 | one - | | six -(5 rows) - -DROP TABLE UNIQUE_TBL; diff --git a/src/test/regress/expected/copy.out b/src/test/regress/expected/copy.out deleted file mode 100644 index 96c639d..0000000 --- a/src/test/regress/expected/copy.out +++ /dev/null @@ -1,73 +0,0 @@ --- --- COPY --- --- CLASS POPULATION --- (any resemblance to real life is purely coincidental) --- -COPY aggtest FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/agg.data'; -COPY onek FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/onek.data'; -COPY onek TO '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/results/onek.data'; -DELETE FROM onek; -COPY onek FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/results/onek.data'; -COPY tenk1 FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/tenk.data'; -COPY slow_emp4000 FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/rect.data'; -COPY person FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/person.data'; -COPY emp FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/emp.data'; -COPY student FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/student.data'; -COPY stud_emp FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/stud_emp.data'; -COPY road FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/streets.data'; -COPY real_city FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/real_city.data'; -COPY hash_i4_heap FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/hash.data'; -COPY hash_name_heap FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/hash.data'; -COPY hash_txt_heap FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/hash.data'; -COPY hash_f8_heap FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/hash.data'; -COPY test_tsvector FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/tsearch.data'; --- the data in this file has a lot of duplicates in the index key --- fields, leading to long bucket chains and lots of table expansion. --- this is therefore a stress test of the bucket overflow code (unlike --- the data in hash.data, which has unique index keys). --- --- COPY hash_ovfl_heap FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/hashovfl.data'; -COPY bt_i4_heap FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/desc.data'; -COPY bt_name_heap FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/hash.data'; -COPY bt_txt_heap FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/desc.data'; -COPY bt_f8_heap FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/hash.data'; -COPY array_op_test FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/array.data'; -COPY array_index_op_test FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/array.data'; ---- test copying in CSV mode with various styles ---- of embedded line ending characters -create temp table copytest ( - style text, - test text, - filler int); -insert into copytest values('DOS',E'abc\r\ndef',1); -insert into copytest values('Unix',E'abc\ndef',2); -insert into copytest values('Mac',E'abc\rdef',3); -insert into copytest values(E'esc\\ape',E'a\\r\\\r\\\n\\nb',4); -copy copytest to '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/results/copytest.csv' csv; -create temp table copytest2 (like copytest); -copy copytest2 from '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/results/copytest.csv' csv; -select * from copytest except select * from copytest2; - style | test | filler --------+------+-------- -(0 rows) - -truncate copytest2; ---- same test but with an escape char different from quote char -copy copytest to '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/results/copytest.csv' csv quote '''' escape E'\\'; -copy copytest2 from '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/results/copytest.csv' csv quote '''' escape E'\\'; -select * from copytest except select * from copytest2; - style | test | filler --------+------+-------- -(0 rows) - --- test header line feature -create temp table copytest3 ( - c1 int, - "col with , comma" text, - "col with "" quote" int); -copy copytest3 from stdin csv header; -copy copytest3 to stdout csv header; -c1,"col with , comma","col with "" quote" -1,a,1 -2,b,2 diff --git a/src/test/regress/expected/create_function_1.out b/src/test/regress/expected/create_function_1.out deleted file mode 100644 index e30788d..0000000 --- a/src/test/regress/expected/create_function_1.out +++ /dev/null @@ -1,82 +0,0 @@ --- --- CREATE_FUNCTION_1 --- -CREATE FUNCTION widget_in(cstring) - RETURNS widget - AS '/Users/masonsharp/dev/pgxc/postgres-xc/inst/lib/regress.so' - LANGUAGE C STRICT; -NOTICE: type "widget" is not yet defined -DETAIL: Creating a shell type definition. -CREATE FUNCTION widget_out(widget) - RETURNS cstring - AS '/Users/masonsharp/dev/pgxc/postgres-xc/inst/lib/regress.so' - LANGUAGE C STRICT; -NOTICE: argument type widget is only a shell -CREATE FUNCTION int44in(cstring) - RETURNS city_budget - AS '/Users/masonsharp/dev/pgxc/postgres-xc/inst/lib/regress.so' - LANGUAGE C STRICT; -NOTICE: type "city_budget" is not yet defined -DETAIL: Creating a shell type definition. -CREATE FUNCTION int44out(city_budget) - RETURNS cstring - AS '/Users/masonsharp/dev/pgxc/postgres-xc/inst/lib/regress.so' - LANGUAGE C STRICT; -NOTICE: argument type city_budget is only a shell -CREATE FUNCTION check_primary_key () - RETURNS trigger - AS '/Users/masonsharp/dev/pgxc/postgres-xc/inst/lib/refint.so' - LANGUAGE C; -CREATE FUNCTION check_foreign_key () - RETURNS trigger - AS '/Users/masonsharp/dev/pgxc/postgres-xc/inst/lib/refint.so' - LANGUAGE C; -CREATE FUNCTION autoinc () - RETURNS trigger - AS '/Users/masonsharp/dev/pgxc/postgres-xc/inst/lib/autoinc.so' - LANGUAGE C; -CREATE FUNCTION funny_dup17 () - RETURNS trigger - AS '/Users/masonsharp/dev/pgxc/postgres-xc/inst/lib/regress.so' - LANGUAGE C; -CREATE FUNCTION ttdummy () - RETURNS trigger - AS '/Users/masonsharp/dev/pgxc/postgres-xc/inst/lib/regress.so' - LANGUAGE C; -CREATE FUNCTION set_ttdummy (int4) - RETURNS int4 - AS '/Users/masonsharp/dev/pgxc/postgres-xc/inst/lib/regress.so' - LANGUAGE C STRICT; --- Things that shouldn't work: -CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL - AS 'SELECT ''not an integer'';'; -ERROR: return type mismatch in function declared to return integer -DETAIL: Actual return type is unknown. -CONTEXT: SQL function "test1" -CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL - AS 'not even SQL'; -ERROR: syntax error at or near "not" -LINE 2: AS 'not even SQL'; - ^ -CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL - AS 'SELECT 1, 2, 3;'; -ERROR: return type mismatch in function declared to return integer -DETAIL: Final statement must return exactly one column. -CONTEXT: SQL function "test1" -CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL - AS 'SELECT $2;'; -ERROR: there is no parameter $2 -LINE 2: AS 'SELECT $2;'; - ^ -CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL - AS 'a', 'b'; -ERROR: only one AS item needed for language "sql" -CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C - AS 'nosuchfile'; -ERROR: could not access file "nosuchfile": No such file or directory -CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C - AS '/Users/masonsharp/dev/pgxc/postgres-xc/inst/lib/regress.so', 'nosuchsymbol'; -ERROR: could not find function "nosuchsymbol" in file "/Users/masonsharp/dev/pgxc/postgres-xc/inst/lib/regress.so" -CREATE FUNCTION test1 (int) RETURNS int LANGUAGE internal - AS 'nosuch'; -ERROR: there is no built-in function named "nosuch" diff --git a/src/test/regress/expected/create_function_2.out b/src/test/regress/expected/create_function_2.out deleted file mode 100644 index a9031f1..0000000 --- a/src/test/regress/expected/create_function_2.out +++ /dev/null @@ -1,57 +0,0 @@ --- --- CREATE_FUNCTION_2 --- -CREATE FUNCTION hobbies(person) - RETURNS setof hobbies_r - AS 'select * from hobbies_r where person = $1.name' - LANGUAGE SQL; -CREATE FUNCTION hobby_construct(text, text) - RETURNS hobbies_r - AS 'select $1 as name, $2 as hobby' - LANGUAGE SQL; -CREATE FUNCTION hobbies_by_name(hobbies_r.name%TYPE) - RETURNS hobbies_r.person%TYPE - AS 'select person from hobbies_r where name = $1' - LANGUAGE SQL; -NOTICE: type reference hobbies_r.name%TYPE converted to text -NOTICE: type reference hobbies_r.person%TYPE converted to text -CREATE FUNCTION equipment(hobbies_r) - RETURNS setof equipment_r - AS 'select * from equipment_r where hobby = $1.name' - LANGUAGE SQL; -CREATE FUNCTION user_relns() - RETURNS setof name - AS 'select relname - from pg_class c, pg_namespace n - where relnamespace = n.oid and - (nspname !~ ''pg_.*'' and nspname <> ''information_schema'') and - relkind <> ''i'' ' - LANGUAGE SQL; -CREATE FUNCTION pt_in_widget(point, widget) - RETURNS bool - AS '/Users/masonsharp/dev/pgxc/postgres-xc/inst/lib/regress.so' - LANGUAGE C; -CREATE FUNCTION overpaid(emp) - RETURNS bool - AS '/Users/masonsharp/dev/pgxc/postgres-xc/inst/lib/regress.so' - LANGUAGE C; -CREATE FUNCTION boxarea(box) - RETURNS float8 - AS '/Users/masonsharp/dev/pgxc/postgres-xc/inst/lib/regress.so' - LANGUAGE C; -CREATE FUNCTION interpt_pp(path, path) - RETURNS point - AS '/Users/masonsharp/dev/pgxc/postgres-xc/inst/lib/regress.so' - LANGUAGE C; -CREATE FUNCTION reverse_name(name) - RETURNS name - AS '/Users/masonsharp/dev/pgxc/postgres-xc/inst/lib/regress.so' - LANGUAGE C; -CREATE FUNCTION oldstyle_length(int4, text) - RETURNS int4 - AS '/Users/masonsharp/dev/pgxc/postgres-xc/inst/lib/regress.so' - LANGUAGE C; --- --- Function dynamic loading --- -LOAD '/Users/masonsharp/dev/pgxc/postgres-xc/inst/lib/regress.so'; diff --git a/src/test/regress/expected/largeobject.out b/src/test/regress/expected/largeobject.out deleted file mode 100644 index e71b608..0000000 --- a/src/test/regress/expected/largeobject.out +++ /dev/null @@ -1,284 +0,0 @@ --- --- Test large object support --- --- Load a file -CREATE TABLE lotest_stash_values (loid oid, fd integer); --- lo_creat(mode integer) returns oid --- The mode arg to lo_creat is unused, some vestigal holdover from ancient times --- returns the large object id -INSERT INTO lotest_stash_values (loid) SELECT lo_creat(42); --- NOTE: large objects require transactions -BEGIN; --- lo_open(lobjId oid, mode integer) returns integer --- The mode parameter to lo_open uses two constants: --- INV_READ = 0x20000 --- INV_WRITE = 0x40000 --- The return value is a file descriptor-like value which remains valid for the --- transaction. -UPDATE lotest_stash_values SET fd = lo_open(loid, CAST(x'20000' | x'40000' AS integer)); --- loread/lowrite names are wonky, different from other functions which are lo_* --- lowrite(fd integer, data bytea) returns integer --- the integer is the number of bytes written -SELECT lowrite(fd, ' -Whose woods these are I think I know, -His house is in the village though. -He will not see me stopping here, -To watch his woods fill up with snow. - -My little horse must think it queer, -To stop without a farmhouse near, -Between the woods and frozen lake, -The darkest evening of the year. - -He gives his harness bells a shake, -To ask if there is some mistake. -The only other sound''s the sweep, -Of easy wind and downy flake. - -The woods are lovely, dark and deep, -But I have promises to keep, -And miles to go before I sleep, -And miles to go before I sleep. - - -- Robert Frost -') FROM lotest_stash_values; - lowrite ---------- - 578 -(1 row) - --- lo_close(fd integer) returns integer --- return value is 0 for success, or <0 for error (actually only -1, but...) -SELECT lo_close(fd) FROM lotest_stash_values; - lo_close ----------- - 0 -(1 row) - -END; --- Read out a portion -BEGIN; -UPDATE lotest_stash_values SET fd=lo_open(loid, CAST(x'20000' | x'40000' AS integer)); --- lo_lseek(fd integer, offset integer, whence integer) returns integer --- offset is in bytes, whence is one of three values: --- SEEK_SET (= 0) meaning relative to beginning --- SEEK_CUR (= 1) meaning relative to current position --- SEEK_END (= 2) meaning relative to end (offset better be negative) --- returns current position in file -SELECT lo_lseek(fd, 422, 0) FROM lotest_stash_values; - lo_lseek ----------- - 422 -(1 row) - --- loread/lowrite names are wonky, different from other functions which are lo_* --- loread(fd integer, len integer) returns bytea -SELECT loread(fd, 35) FROM lotest_stash_values; - loread -------------------------------------- - The woods are lovely, dark and deep -(1 row) - -SELECT lo_lseek(fd, -19, 1) FROM lotest_stash_values; - lo_lseek ----------- - 438 -(1 row) - -SELECT lowrite(fd, 'n') FROM lotest_stash_values; - lowrite ---------- - 1 -(1 row) - -SELECT lo_tell(fd) FROM lotest_stash_values; - lo_tell ---------- - 439 -(1 row) - -SELECT lo_lseek(fd, -156, 2) FROM lotest_stash_values; - lo_lseek ----------- - 422 -(1 row) - -SELECT loread(fd, 35) FROM lotest_stash_values; - loread -------------------------------------- - The woods are lonely, dark and deep -(1 row) - -SELECT lo_close(fd) FROM lotest_stash_values; - lo_close ----------- - 0 -(1 row) - -END; --- Test resource management -BEGIN; -SELECT lo_open(loid, x'40000'::int) from lotest_stash_values; - lo_open ---------- - 0 -(1 row) - -ABORT; --- Test truncation. -BEGIN; -UPDATE lotest_stash_values SET fd=lo_open(loid, CAST(x'20000' | x'40000' AS integer)); -SELECT lo_truncate(fd, 10) FROM lotest_stash_values; - lo_truncate -------------- - 0 -(1 row) - -SELECT loread(fd, 15) FROM lotest_stash_values; - loread ---------------- - \012Whose woo -(1 row) - -SELECT lo_truncate(fd, 10000) FROM lotest_stash_values; - lo_truncate -------------- - 0 -(1 row) - -SELECT loread(fd, 10) FROM lotest_stash_values; - loread ------------------------------------------- - \000\000\000\000\000\000\000\000\000\000 -(1 row) - -SELECT lo_lseek(fd, 0, 2) FROM lotest_stash_values; - lo_lseek ----------- - 10000 -(1 row) - -SELECT lo_tell(fd) FROM lotest_stash_values; - lo_tell ---------- - 10000 -(1 row) - -SELECT lo_truncate(fd, 5000) FROM lotest_stash_values; - lo_truncate -------------- - 0 -(1 row) - -SELECT lo_lseek(fd, 0, 2) FROM lotest_stash_values; - lo_lseek ----------- - 5000 -(1 row) - -SELECT lo_tell(fd) FROM lotest_stash_values; - lo_tell ---------- - 5000 -(1 row) - -SELECT lo_close(fd) FROM lotest_stash_values; - lo_close ----------- - 0 -(1 row) - -END; --- lo_unlink(lobjId oid) returns integer --- return value appears to always be 1 -SELECT lo_unlink(loid) from lotest_stash_values; - lo_unlink ------------ - 1 -(1 row) - -TRUNCATE lotest_stash_values; -INSERT INTO lotest_stash_values (loid) SELECT lo_import('/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/tenk.data'); -BEGIN; -UPDATE lotest_stash_values SET fd=lo_open(loid, CAST(x'20000' | x'40000' AS integer)); --- with the default BLKSZ, LOBLKSZ = 2048, so this positions us for a block --- edge case -SELECT lo_lseek(fd, 2030, 0) FROM lotest_stash_values; - lo_lseek ----------- - 2030 -(1 row) - --- this should get half of the value from page 0 and half from page 1 of the --- large object -SELECT loread(fd, 36) FROM lotest_stash_values; - loread ------------------------------------------------------------------ - AAA\011FBAAAA\011VVVVxx\0122513\01132\0111\0111\0113\01113\0111 -(1 row) - -SELECT lo_tell(fd) FROM lotest_stash_values; - lo_tell ---------- - 2066 -(1 row) - -SELECT lo_lseek(fd, -26, 1) FROM lotest_stash_values; - lo_lseek ----------- - 2040 -(1 row) - -SELECT lowrite(fd, 'abcdefghijklmnop') FROM lotest_stash_values; - lowrite ---------- - 16 -(1 row) - -SELECT lo_lseek(fd, 2030, 0) FROM lotest_stash_values; - lo_lseek ----------- - 2030 -(1 row) - -SELECT loread(fd, 36) FROM lotest_stash_values; - loread ------------------------------------------------------ - AAA\011FBAAAAabcdefghijklmnop1\0111\0113\01113\0111 -(1 row) - -SELECT lo_close(fd) FROM lotest_stash_values; - lo_close ----------- - 0 -(1 row) - -END; -SELECT lo_export(loid, '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/results/lotest.txt') FROM lotest_stash_values; - lo_export ------------ - 1 -(1 row) - -\lo_import 'results/lotest.txt' -\set newloid :LASTOID --- just make sure \lo_export does not barf -\lo_export :newloid 'results/lotest2.txt' --- This is a hack to test that export/import are reversible --- This uses knowledge about the inner workings of large object mechanism --- which should not be used outside it. This makes it a HACK -SELECT pageno, data FROM pg_largeobject WHERE loid = (SELECT loid from lotest_stash_values) -EXCEPT -SELECT pageno, data FROM pg_largeobject WHERE loid = :newloid; - pageno | data ---------+------ -(0 rows) - -SELECT lo_unlink(loid) FROM lotest_stash_values; - lo_unlink ------------ - 1 -(1 row) - -\lo_unlink :newloid -TRUNCATE lotest_stash_values; diff --git a/src/test/regress/expected/largeobject_1.out b/src/test/regress/expected/largeobject_1.out deleted file mode 100644 index 5fe7cae..0000000 --- a/src/test/regress/expected/largeobject_1.out +++ /dev/null @@ -1,284 +0,0 @@ --- --- Test large object support --- --- Load a file -CREATE TABLE lotest_stash_values (loid oid, fd integer); --- lo_creat(mode integer) returns oid --- The mode arg to lo_creat is unused, some vestigal holdover from ancient times --- returns the large object id -INSERT INTO lotest_stash_values (loid) SELECT lo_creat(42); --- NOTE: large objects require transactions -BEGIN; --- lo_open(lobjId oid, mode integer) returns integer --- The mode parameter to lo_open uses two constants: --- INV_READ = 0x20000 --- INV_WRITE = 0x40000 --- The return value is a file descriptor-like value which remains valid for the --- transaction. -UPDATE lotest_stash_values SET fd = lo_open(loid, CAST(x'20000' | x'40000' AS integer)); --- loread/lowrite names are wonky, different from other functions which are lo_* --- lowrite(fd integer, data bytea) returns integer --- the integer is the number of bytes written -SELECT lowrite(fd, ' -Whose woods these are I think I know, -His house is in the village though. -He will not see me stopping here, -To watch his woods fill up with snow. - -My little horse must think it queer, -To stop without a farmhouse near, -Between the woods and frozen lake, -The darkest evening of the year. - -He gives his harness bells a shake, -To ask if there is some mistake. -The only other sound''s the sweep, -Of easy wind and downy flake. - -The woods are lovely, dark and deep, -But I have promises to keep, -And miles to go before I sleep, -And miles to go before I sleep. - - -- Robert Frost -') FROM lotest_stash_values; - lowrite ---------- - 578 -(1 row) - --- lo_close(fd integer) returns integer --- return value is 0 for success, or <0 for error (actually only -1, but...) -SELECT lo_close(fd) FROM lotest_stash_values; - lo_close ----------- - 0 -(1 row) - -END; --- Read out a portion -BEGIN; -UPDATE lotest_stash_values SET fd=lo_open(loid, CAST(x'20000' | x'40000' AS integer)); --- lo_lseek(fd integer, offset integer, whence integer) returns integer --- offset is in bytes, whence is one of three values: --- SEEK_SET (= 0) meaning relative to beginning --- SEEK_CUR (= 1) meaning relative to current position --- SEEK_END (= 2) meaning relative to end (offset better be negative) --- returns current position in file -SELECT lo_lseek(fd, 422, 0) FROM lotest_stash_values; - lo_lseek ----------- - 422 -(1 row) - --- loread/lowrite names are wonky, different from other functions which are lo_* --- loread(fd integer, len integer) returns bytea -SELECT loread(fd, 35) FROM lotest_stash_values; - loread -------------------------------------- - The woods are lovely, dark and deep -(1 row) - -SELECT lo_lseek(fd, -19, 1) FROM lotest_stash_values; - lo_lseek ----------- - 438 -(1 row) - -SELECT lowrite(fd, 'n') FROM lotest_stash_values; - lowrite ---------- - 1 -(1 row) - -SELECT lo_tell(fd) FROM lotest_stash_values; - lo_tell ---------- - 439 -(1 row) - -SELECT lo_lseek(fd, -156, 2) FROM lotest_stash_values; - lo_lseek ----------- - 422 -(1 row) - -SELECT loread(fd, 35) FROM lotest_stash_values; - loread -------------------------------------- - The woods are lonely, dark and deep -(1 row) - -SELECT lo_close(fd) FROM lotest_stash_values; - lo_close ----------- - 0 -(1 row) - -END; --- Test resource management -BEGIN; -SELECT lo_open(loid, x'40000'::int) from lotest_stash_values; - lo_open ---------- - 0 -(1 row) - -ABORT; --- Test truncation. -BEGIN; -UPDATE lotest_stash_values SET fd=lo_open(loid, CAST(x'20000' | x'40000' AS integer)); -SELECT lo_truncate(fd, 10) FROM lotest_stash_values; - lo_truncate -------------- - 0 -(1 row) - -SELECT loread(fd, 15) FROM lotest_stash_values; - loread ---------------- - \012Whose woo -(1 row) - -SELECT lo_truncate(fd, 10000) FROM lotest_stash_values; - lo_truncate -------------- - 0 -(1 row) - -SELECT loread(fd, 10) FROM lotest_stash_values; - loread ------------------------------------------- - \000\000\000\000\000\000\000\000\000\000 -(1 row) - -SELECT lo_lseek(fd, 0, 2) FROM lotest_stash_values; - lo_lseek ----------- - 10000 -(1 row) - -SELECT lo_tell(fd) FROM lotest_stash_values; - lo_tell ---------- - 10000 -(1 row) - -SELECT lo_truncate(fd, 5000) FROM lotest_stash_values; - lo_truncate -------------- - 0 -(1 row) - -SELECT lo_lseek(fd, 0, 2) FROM lotest_stash_values; - lo_lseek ----------- - 5000 -(1 row) - -SELECT lo_tell(fd) FROM lotest_stash_values; - lo_tell ---------- - 5000 -(1 row) - -SELECT lo_close(fd) FROM lotest_stash_values; - lo_close ----------- - 0 -(1 row) - -END; --- lo_unlink(lobjId oid) returns integer --- return value appears to always be 1 -SELECT lo_unlink(loid) from lotest_stash_values; - lo_unlink ------------ - 1 -(1 row) - -TRUNCATE lotest_stash_values; -INSERT INTO lotest_stash_values (loid) SELECT lo_import('/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/data/tenk.data'); -BEGIN; -UPDATE lotest_stash_values SET fd=lo_open(loid, CAST(x'20000' | x'40000' AS integer)); --- with the default BLKSZ, LOBLKSZ = 2048, so this positions us for a block --- edge case -SELECT lo_lseek(fd, 2030, 0) FROM lotest_stash_values; - lo_lseek ----------- - 2030 -(1 row) - --- this should get half of the value from page 0 and half from page 1 of the --- large object -SELECT loread(fd, 36) FROM lotest_stash_values; - loread --------------------------------------------------------------- - 44\011144\0111144\0114144\0119144\01188\01189\011SNAAAA\011F -(1 row) - -SELECT lo_tell(fd) FROM lotest_stash_values; - lo_tell ---------- - 2066 -(1 row) - -SELECT lo_lseek(fd, -26, 1) FROM lotest_stash_values; - lo_lseek ----------- - 2040 -(1 row) - -SELECT lowrite(fd, 'abcdefghijklmnop') FROM lotest_stash_values; - lowrite ---------- - 16 -(1 row) - -SELECT lo_lseek(fd, 2030, 0) FROM lotest_stash_values; - lo_lseek ----------- - 2030 -(1 row) - -SELECT loread(fd, 36) FROM lotest_stash_values; - loread --------------------------------------------------- - 44\011144\011114abcdefghijklmnop9\011SNAAAA\011F -(1 row) - -SELECT lo_close(fd) FROM lotest_stash_values; - lo_close ----------- - 0 -(1 row) - -END; -SELECT lo_export(loid, '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/results/lotest.txt') FROM lotest_stash_values; - lo_export ------------ - 1 -(1 row) - -\lo_import 'results/lotest.txt' -\set newloid :LASTOID --- just make sure \lo_export does not barf -\lo_export :newloid 'results/lotest2.txt' --- This is a hack to test that export/import are reversible --- This uses knowledge about the inner workings of large object mechanism --- which should not be used outside it. This makes it a HACK -SELECT pageno, data FROM pg_largeobject WHERE loid = (SELECT loid from lotest_stash_values) -EXCEPT -SELECT pageno, data FROM pg_largeobject WHERE loid = :newloid; - pageno | data ---------+------ -(0 rows) - -SELECT lo_unlink(loid) FROM lotest_stash_values; - lo_unlink ------------ - 1 -(1 row) - -\lo_unlink :newloid -TRUNCATE lotest_stash_values; diff --git a/src/test/regress/expected/misc.out b/src/test/regress/expected/misc.out deleted file mode 100644 index 5a53260..0000000 --- a/src/test/regress/expected/misc.out +++ /dev/null @@ -1,761 +0,0 @@ --- --- MISC --- --- --- BTREE --- -UPDATE onek - SET unique1 = onek.unique1 + 1; -UPDATE onek - SET unique1 = onek.unique1 - 1; --- --- BTREE partial --- --- UPDATE onek2 --- SET unique1 = onek2.unique1 + 1; ---UPDATE onek2 --- SET unique1 = onek2.unique1 - 1; --- --- BTREE shutting out non-functional updates --- --- the following two tests seem to take a long time on some --- systems. This non-func update stuff needs to be examined --- more closely. - jolly (2/22/96) --- -UPDATE tmp - SET stringu1 = reverse_name(onek.stringu1) - FROM onek - WHERE onek.stringu1 = 'JBAAAA' and - onek.stringu1 = tmp.stringu1; -UPDATE tmp - SET stringu1 = reverse_name(onek2.stringu1) - FROM onek2 - WHERE onek2.stringu1 = 'JCAAAA' and - onek2.stringu1 = tmp.stringu1; -DROP TABLE tmp; ---UPDATE person* --- SET age = age + 1; ---UPDATE person* --- SET age = age + 3 --- WHERE name = 'linda'; --- --- copy --- -COPY onek TO '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/results/onek.data'; -DELETE FROM onek; -COPY onek FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/results/onek.data'; -SELECT unique1 FROM onek WHERE unique1 < 2 ORDER BY unique1; - unique1 ---------- - 0 - 1 -(2 rows) - -DELETE FROM onek2; -COPY onek2 FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/results/onek.data'; -SELECT unique1 FROM onek2 WHERE unique1 < 2 ORDER BY unique1; - unique1 ---------- - 0 - 1 -(2 rows) - -COPY BINARY stud_emp TO '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/results/stud_emp.data'; -DELETE FROM stud_emp; -COPY BINARY stud_emp FROM '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/results/stud_emp.data'; -SELECT * FROM stud_emp ORDER BY 1, 2; - name | age | location | salary | manager | gpa | percent --------+-----+------------+--------+---------+-----+--------- - cim | 30 | (10.5,4.7) | 400 | | 3.4 | - jeff | 23 | (8,7.7) | 600 | sharon | 3.5 | - linda | 19 | (0.9,6.1) | 100 | | 2.9 | -(3 rows) - --- COPY aggtest FROM stdin; --- 56 7.8 --- 100 99.097 --- 0 0.09561 --- 42 324.78 --- . --- COPY aggtest TO stdout; --- --- inheritance stress test --- -SELECT * FROM a_star* ORDER BY 1,2; - class | a --------+---- - a | 1 - a | 2 - a | - b | 3 - b | 4 - b | - b | - c | 5 - c | 6 - c | - c | - d | 7 - d | 8 - d | 9 - d | 10 - d | 11 - d | 12 - d | 13 - d | 14 - d | - d | - d | - d | - d | - d | - d | - d | - e | 15 - e | 16 - e | 17 - e | 18 - e | - e | - e | - f | 19 - f | 20 - f | 21 - f | 22 - f | 24 - f | 25 - f | 26 - f | 27 - f | - f | - f | - f | - f | - f | - f | - f | -(50 rows) - -SELECT * - FROM b_star* x - WHERE x.b = text 'bumble' or x.a < 3; - class | a | b --------+---+-------- - b | | bumble -(1 row) - -SELECT class, a - FROM c_star* x - WHERE x.c ~ text 'hi' ORDER BY 1,2; - class | a --------+---- - c | 5 - c | - d | 7 - d | 8 - d | 10 - d | 12 - d | - d | - d | - d | - e | 15 - e | 16 - e | - e | - f | 19 - f | 20 - f | 21 - f | 24 - f | - f | - f | - f | -(22 rows) - -SELECT class, b, c - FROM d_star* x - WHERE x.a < 100 ORDER BY 1,2,3; - class | b | c --------+---------+------------ - d | fumble | - d | grumble | hi sunita - d | rumble | - d | stumble | hi koko - d | | hi avi - d | | hi kristin - d | | - d | | -(8 rows) - -SELECT class, c FROM e_star* x WHERE x.c NOTNULL ORDER BY 1,2; - class | c --------+------------- - e | hi bob - e | hi carol - e | hi elisa - e | hi michelle - f | hi allison - f | hi carl - f | hi claire - f | hi jeff - f | hi keith - f | hi marc - f | hi marcel - f | hi mike -(12 rows) - -SELECT * FROM f_star* x WHERE x.c ISNULL ORDER BY 1,2; - class | a | c | e | f --------+----+---+-----+------------------------------------------- - f | 22 | | -7 | ((111,555),(222,666),(333,777),(444,888)) - f | 25 | | -9 | - f | 26 | | | ((11111,33333),(22222,44444)) - f | 27 | | | - f | | | -11 | ((1111111,3333333),(2222222,4444444)) - f | | | -12 | - f | | | | ((11111111,33333333),(22222222,44444444)) - f | | | | -(8 rows) - --- grouping and aggregation on inherited sets have been busted in the past... -SELECT sum(a) FROM a_star*; - sum ------ - 355 -(1 row) - -SELECT class, sum(a) FROM a_star* GROUP BY class ORDER BY class; - class | sum --------+----- - a | 3 - b | 7 - c | 11 - d | 84 - e | 66 - f | 184 -(6 rows) - -ALTER TABLE f_star RENAME COLUMN f TO ff; -ALTER TABLE e_star* RENAME COLUMN e TO ee; -ALTER TABLE d_star* RENAME COLUMN d TO dd; -ALTER TABLE c_star* RENAME COLUMN c TO cc; -ALTER TABLE b_star* RENAME COLUMN b TO bb; -ALTER TABLE a_star* RENAME COLUMN a TO aa; -SELECT class, aa - FROM a_star* x - WHERE aa ISNULL ORDER BY 1,2; - class | aa --------+---- - a | - b | - b | - c | - c | - d | - d | - d | - d | - d | - d | - d | - d | - e | - e | - e | - f | - f | - f | - f | - f | - f | - f | - f | -(24 rows) - --- As of Postgres 7.1, ALTER implicitly recurses, --- so this should be same as ALTER a_star* -ALTER TABLE a_star RENAME COLUMN aa TO foo; -SELECT class, foo - FROM a_star* x - WHERE x.foo >= 2 ORDER BY 1,2; - class | foo --------+----- - a | 2 - b | 3 - b | 4 - c | 5 - c | 6 - d | 7 - d | 8 - d | 9 - d | 10 - d | 11 - d | 12 - d | 13 - d | 14 - e | 15 - e | 16 - e | 17 - e | 18 - f | 19 - f | 20 - f | 21 - f | 22 - f | 24 - f | 25 - f | 26 - f | 27 -(25 rows) - -ALTER TABLE a_star RENAME COLUMN foo TO aa; -SELECT * - from a_star* - WHERE aa < 1000 ORDER BY 1,2; - class | aa --------+---- - a | 1 - a | 2 - b | 3 - b | 4 - c | 5 - c | 6 - d | 7 - d | 8 - d | 9 - d | 10 - d | 11 - d | 12 - d | 13 - d | 14 - e | 15 - e | 16 - e | 17 - e | 18 - f | 19 - f | 20 - f | 21 - f | 22 - f | 24 - f | 25 - f | 26 - f | 27 -(26 rows) - -ALTER TABLE f_star ADD COLUMN f int4; -UPDATE f_star SET f = 10; -ALTER TABLE e_star* ADD COLUMN e int4; ---UPDATE e_star* SET e = 42; -SELECT * FROM e_star* ORDER BY 1,2; - class | aa | cc | ee | e --------+----+-------------+-----+--- - e | 15 | hi carol | -1 | - e | 16 | hi bob | | - e | 17 | | -2 | - e | 18 | | | - e | | hi elisa | | - e | | | -4 | - e | | hi michelle | -3 | - f | 19 | hi claire | -5 | - f | 20 | hi mike | -6 | - f | 21 | hi marcel | | - f | 22 | | -7 | - f | 24 | hi marc | | - f | 25 | | -9 | - f | 26 | | | - f | 27 | | | - f | | | | - f | | hi keith | -8 | - f | | hi allison | -10 | - f | | hi jeff | | - f | | | -11 | - f | | hi carl | | - f | | | -12 | - f | | | | -(23 rows) - -ALTER TABLE a_star* ADD COLUMN a text; -NOTICE: merging definition of column "a" for child "d_star" ---UPDATE b_star* --- SET a = text 'gazpacho' --- WHERE aa > 4; -SELECT class, aa, a FROM a_star* ORDER BY 1,2; - class | aa | a --------+----+--- - a | 1 | - a | 2 | - a | | - b | 3 | - b | 4 | - b | | - b | | - c | 5 | - c | 6 | - c | | - c | | - d | 7 | - d | 8 | - d | 9 | - d | 10 | - d | 11 | - d | 12 | - d | 13 | - d | 14 | - d | | - d | | - d | | - d | | - d | | - d | | - d | | - d | | - e | 15 | - e | 16 | - e | 17 | - e | 18 | - e | | - e | | - e | | - f | 19 | - f | 20 | - f | 21 | - f | 22 | - f | 24 | - f | 25 | - f | 26 | - f | 27 | - f | | - f | | - f | | - f | | - f | | - f | | - f | | - f | | -(50 rows) - --- --- versions --- --- --- postquel functions --- --- --- mike does post_hacking, --- joe and sally play basketball, and --- everyone else does nothing. --- -SELECT p.name, name(p.hobbies) FROM ONLY person p ORDER BY 1,2; - name | name --------+------------- - joe | basketball - mike | posthacking - sally | basketball -(3 rows) - --- --- as above, but jeff also does post_hacking. --- -SELECT p.name, name(p.hobbies) FROM person* p ORDER BY 1,2; - name | name --------+------------- - jeff | posthacking - joe | basketball - mike | posthacking - sally | basketball -(4 rows) - --- --- the next two queries demonstrate how functions generate bogus duplicates. --- this is a "feature" .. --- -SELECT DISTINCT hobbies_r.name, name(hobbies_r.equipment) FROM hobbies_r - ORDER BY 1,2; - name | name --------------+--------------- - basketball | hightops - posthacking | advil - posthacking | peet's coffee - skywalking | guts -(4 rows) - -SELECT hobbies_r.name, (hobbies_r.equipment).name FROM hobbies_r ORDER BY 1,2; - name | name --------------+--------------- - basketball | hightops - basketball | hightops - posthacking | advil - posthacking | advil - posthacking | peet's coffee - posthacking | peet's coffee - skywalking | guts -(7 rows) - --- --- mike needs advil and peet's coffee, --- joe and sally need hightops, and --- everyone else is fine. --- -SELECT p.name, name(p.hobbies), name(equipment(p.hobbies)) FROM ONLY person p ORDER BY 1,2,3; - name | name | name --------+-------------+--------------- - joe | basketball | hightops - mike | posthacking | advil - mike | posthacking | peet's coffee - sally | basketball | hightops -(4 rows) - --- --- as above, but jeff needs advil and peet's coffee as well. --- -SELECT p.name, name(p.hobbies), name(equipment(p.hobbies)) FROM person* p ORDER BY 1,2,3; - name | name | name --------+-------------+--------------- - jeff | posthacking | advil - jeff | posthacking | peet's coffee - joe | basketball | hightops - mike | posthacking | advil - mike | posthacking | peet's coffee - sally | basketball | hightops -(6 rows) - --- --- just like the last two, but make sure that the target list fixup and --- unflattening is being done correctly. --- -SELECT name(equipment(p.hobbies)), p.name, name(p.hobbies) FROM ONLY person p ORDER BY 1,2,3; - name | name | name ----------------+-------+------------- - advil | mike | posthacking - hightops | joe | basketball - hightops | sally | basketball - peet's coffee | mike | posthacking -(4 rows) - -SELECT (p.hobbies).equipment.name, p.name, name(p.hobbies) FROM person* p ORDER BY 1,2,3; - name | name | name ----------------+-------+------------- - advil | jeff | posthacking - advil | mike | posthacking - hightops | joe | basketball - hightops | sally | basketball - peet's coffee | jeff | posthacking - peet's coffee | mike | posthacking -(6 rows) - -SELECT (p.hobbies).equipment.name, name(p.hobbies), p.name FROM ONLY person p ORDER BY 1,2,3; - name | name | name ----------------+-------------+------- - advil | posthacking | mike - hightops | basketball | joe - hightops | basketball | sally - peet's coffee | posthacking | mike -(4 rows) - -SELECT name(equipment(p.hobbies)), name(p.hobbies), p.name FROM person* p ORDER BY 1,2,3; - name | name | name ----------------+-------------+------- - advil | posthacking | jeff - advil | posthacking | mike - hightops | basketball | joe - hightops | basketball | sally - peet's coffee | posthacking | jeff - peet's coffee | posthacking | mike -(6 rows) - -SELECT user_relns() AS user_relns - ORDER BY user_relns; - user_relns ---------------------- - a - a_star - abstime_tbl - aggtest - array_index_op_test - array_op_test - arrtest - b - b_star - box_tbl - bprime - bt_f8_heap - bt_i4_heap - bt_name_heap - bt_txt_heap - c - c_star - char_tbl - check2_tbl - check_seq - check_tbl - circle_tbl - city - copy_tbl - d - d_star - date_tbl - default_seq - default_tbl - defaultexpr_tbl - dept - e_star - emp - equipment_r - f_star - fast_emp4000 - float4_tbl - float8_tbl - func_index_heap - hash_f8_heap - hash_i4_heap - hash_name_heap - hash_txt_heap - hobbies_r - iexit - ihighway - inet_tbl - inhe - inhf - inhx - insert_seq - insert_tbl - int2_tbl - int4_tbl - int8_tbl - interval_tbl - iportaltest - log_table - lseg_tbl - main_table - money_data - num_data - num_exp_add - num_exp_div - num_exp_ln - num_exp_log10 - num_exp_mul - num_exp_power_10_ln - num_exp_sqrt - num_exp_sub - num_input_test - num_result - onek - onek2 - path_tbl - person - point_tbl - polygon_tbl - ramp - random_tbl - real_city - reltime_tbl - road - shighway - slow_emp4000 - street - stud_emp - student - subselect_tbl - tenk1 - tenk2 - test_tsvector - text_tbl - time_tbl - timestamp_tbl - timestamptz_tbl - timetz_tbl - tinterval_tbl - toyemp - varchar_tbl - xacttest -(101 rows) - -SELECT name(equipment(hobby_construct(text 'skywalking', text 'mer'))); - name ------- - guts -(1 row) - -SELECT hobbies_by_name('basketball'); - hobbies_by_name ------------------ - joe -(1 row) - -SELECT name, overpaid(emp.*) FROM emp ORDER BY 1,2; - name | overpaid ---------+---------- - bill | t - cim | f - jeff | f - linda | f - sam | t - sharon | t -(6 rows) - --- --- Try a few cases with SQL-spec row constructor expressions --- -SELECT * FROM equipment(ROW('skywalking', 'mer')); - name | hobby -------+------------ - guts | skywalking -(1 row) - -SELECT name(equipment(ROW('skywalking', 'mer'))); - name ------- - guts -(1 row) - -SELECT *, name(equipment(h.*)) FROM hobbies_r h ORDER BY 1,2,3; - name | person | name --------------+--------+--------------- - basketball | joe | hightops - basketball | sally | hightops - posthacking | jeff | advil - posthacking | jeff | peet's coffee - posthacking | mike | advil - posthacking | mike | peet's coffee - skywalking | | guts -(7 rows) - -SELECT *, (equipment(CAST((h.*) AS hobbies_r))).name FROM hobbies_r h ORDER BY 1,2,3; - name | person | name --------------+--------+--------------- - basketball | joe | hightops - basketball | sally | hightops - posthacking | jeff | advil - posthacking | jeff | peet's coffee - posthacking | mike | advil - posthacking | mike | peet's coffee - skywalking | | guts -(7 rows) - --- --- check that old-style C functions work properly with TOASTed values --- -create table oldstyle_test(i int4, t text); -insert into oldstyle_test values(null,null); -insert into oldstyle_test values(0,'12'); -insert into oldstyle_test values(1000,'12'); -insert into oldstyle_test values(0, repeat('x', 50000)); -select i, length(t), octet_length(t), oldstyle_length(i,t) from oldstyle_test ORDER BY 1,2,3; - i | length | octet_length | oldstyle_length -------+--------+--------------+----------------- - 0 | 2 | 2 | 2 - 0 | 50000 | 50000 | 50000 - 1000 | 2 | 2 | 1002 - | | | -(4 rows) - -drop table oldstyle_test; --- --- functional joins --- --- --- instance rules --- --- --- rewrite rules --- diff --git a/src/test/regress/expected/tablespace.out b/src/test/regress/expected/tablespace.out deleted file mode 100644 index 4df5192..0000000 --- a/src/test/regress/expected/tablespace.out +++ /dev/null @@ -1,74 +0,0 @@ --- create a tablespace we can use -CREATE TABLESPACE testspace LOCATION '/Users/masonsharp/dev/pgxc/postgres-xc/src/test/regress/testtablespace'; --- create a schema we can use -CREATE SCHEMA testschema; --- try a table -CREATE TABLE testschema.foo (i int) TABLESPACE testspace; -SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c - where c.reltablespace = t.oid AND c.relname = 'foo'; - relname | spcname ----------+----------- - foo | testspace -(1 row) - -INSERT INTO testschema.foo VALUES(1); -INSERT INTO testschema.foo VALUES(2); --- tables from dynamic sources -CREATE TABLE testschema.asselect TABLESPACE testspace AS SELECT 1; -SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c - where c.reltablespace = t.oid AND c.relname = 'asselect'; - relname | spcname -----------+----------- - asselect | testspace -(1 row) - -PREPARE selectsource(int) AS SELECT $1; -CREATE TABLE testschema.asexecute TABLESPACE testspace - AS EXECUTE selectsource(2); -SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c - where c.reltablespace = t.oid AND c.relname = 'asexecute'; - relname | spcname ------------+----------- - asexecute | testspace -(1 row) - --- index -CREATE INDEX foo_idx on testschema.foo(i) TABLESPACE testspace; -SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c - where c.reltablespace = t.oid AND c.relname = 'foo_idx'; - relname | spcname ----------+----------- - foo_idx | testspace -(1 row) - --- let's try moving a table from one place to another -CREATE TABLE testschema.atable AS VALUES (1), (2); -CREATE UNIQUE INDEX anindex ON testschema.atable(column1); -ALTER TABLE testschema.atable SET TABLESPACE testspace; -ALTER INDEX testschema.anindex SET TABLESPACE testspace; -INSERT INTO testschema.atable VALUES(3); -- ok -INSERT INTO testschema.atable VALUES(1); -- fail (checks index) -ERROR: duplicate key value violates unique constraint "anindex" -SELECT COUNT(*) FROM testschema.atable; -- checks heap - count -------- - 3 -(1 row) - --- Will fail with bad path -CREATE TABLESPACE badspace LOCATION '/no/such/location'; -ERROR: could not set permissions on directory "/no/such/location": No such file or directory --- No such tablespace -CREATE TABLE bar (i int) TABLESPACE nosuchspace; -ERROR: tablespace "nosuchspace" does not exist --- Fail, not empty -DROP TABLESPACE testspace; -ERROR: tablespace "testspace" is not empty -DROP SCHEMA testschema CASCADE; -NOTICE: drop cascades to 4 other objects -DETAIL: drop cascades to table testschema.foo -drop cascades to table testschema.asselect -drop cascades to table testschema.asexecute -drop cascades to table testschema.atable --- Should succeed -DROP TABLESPACE testspace; diff --git a/src/test/regress/sql/constraints.sql b/src/test/regress/sql/constraints.sql deleted file mode 100644 index 06528ec..0000000 --- a/src/test/regress/sql/constraints.sql +++ /dev/null @@ -1,261 +0,0 @@ --- --- CONSTRAINTS --- Constraints can be specified with: --- - DEFAULT clause --- - CHECK clauses --- - PRIMARY KEY clauses --- - UNIQUE clauses --- - --- --- DEFAULT syntax --- - -CREATE TABLE DEFAULT_TBL (i int DEFAULT 100, - x text DEFAULT 'vadim', f float8 DEFAULT 123.456); - -INSERT INTO DEFAULT_TBL VALUES (1, 'thomas', 57.0613); -INSERT INTO DEFAULT_TBL VALUES (1, 'bruce'); -INSERT INTO DEFAULT_TBL (i, f) VALUES (2, 987.654); -INSERT INTO DEFAULT_TBL (x) VALUES ('marc'); -INSERT INTO DEFAULT_TBL VALUES (3, null, 1.0); - -SELECT '' AS five, * FROM DEFAULT_TBL ORDER BY i,x,f; - -CREATE SEQUENCE DEFAULT_SEQ; - -CREATE TABLE DEFAULTEXPR_TBL (i1 int DEFAULT 100 + (200-199) * 2, - i2 int DEFAULT nextval('default_seq')); - -INSERT INTO DEFAULTEXPR_TBL VALUES (-1, -2); -INSERT INTO DEFAULTEXPR_TBL (i1) VALUES (-3); -INSERT INTO DEFAULTEXPR_TBL (i2) VALUES (-4); -INSERT INTO DEFAULTEXPR_TBL (i2) VALUES (NULL); - -SELECT '' AS four, * FROM DEFAULTEXPR_TBL ORDER BY i1,i2; - --- syntax errors --- test for extraneous comma -CREATE TABLE error_tbl (i int DEFAULT (100, )); --- this will fail because gram.y uses b_expr not a_expr for defaults, --- to avoid a shift/reduce conflict that arises from NOT NULL being --- part of the column definition syntax: -CREATE TABLE error_tbl (b1 bool DEFAULT 1 IN (1, 2)); --- this should work, however: -CREATE TABLE error_tbl (b1 bool DEFAULT (1 IN (1, 2))); - -DROP TABLE error_tbl; - --- --- CHECK syntax --- - -CREATE TABLE CHECK_TBL (x int, - CONSTRAINT CHECK_CON CHECK (x > 3)); - -INSERT INTO CHECK_TBL VALUES (5); -INSERT INT... [truncated message content] |
From: Michael P. <mic...@us...> - 2011-03-09 00:34:39
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via aadbdfe18024455d5e18cf9007de5b8a3f5135dc (commit) from f9690c125d5657cdf8b4c2d9e441d4fe62edf223 (commit) - Log ----------------------------------------------------------------- commit aadbdfe18024455d5e18cf9007de5b8a3f5135dc Author: Michael P <mic...@us...> Date: Wed Mar 9 09:32:28 2011 +0900 Fix when transforming a CREATE statement A RemoteQuery node was created even if Coordinator was not a remote one. diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 30f5cd9..5b6ba6b 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -278,7 +278,8 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString) stmt->distributeby->disttype = DISTTYPE_HASH; stmt->distributeby->colname = cxt.fallback_dist_col; } - if (IS_PGXC_COORDINATOR) + /* Only a remote Coordinator is allowed to send a query to backend nodes */ + if (IS_PGXC_COORDINATOR && !IsConnFromCoord()) { RemoteQuery *step = makeNode(RemoteQuery); step->combine_type = COMBINE_TYPE_SAME; ----------------------------------------------------------------------- Summary of changes: src/backend/parser/parse_utilcmd.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) hooks/post-receive -- Postgres-XC |
From: Abbas B. <ga...@us...> - 2011-03-08 16:18:11
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via f9690c125d5657cdf8b4c2d9e441d4fe62edf223 (commit) from 60fd3944c0015203d62ae4bb49f209bc0a3b827b (commit) - Log ----------------------------------------------------------------- commit f9690c125d5657cdf8b4c2d9e441d4fe62edf223 Author: Abbas <abb...@en...> Date: Tue Mar 8 21:17:29 2011 +0500 GetRelationLocInfo can return NULL, this patch adds check for a NULL return at missing places diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index 4737067..64eab92 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -855,7 +855,10 @@ AddRelationDistribution (Oid relid, parentOid = linitial_oid(parentOids); rel_loc_info = GetRelationLocInfo(parentOid); - locatortype = rel_loc_info->locatorType; + if (rel_loc_info) + locatortype = rel_loc_info->locatorType; + else + locatortype = LOCATOR_TYPE_REPLICATED; switch (locatortype) { diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index ecd1f52..6114dd2 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -2415,7 +2415,10 @@ create_remotequery_plan(PlannerInfo *root, Path *best_path, rel_loc_info = GetRelationLocInfo(rte->relid); scan_plan->exec_nodes = makeNode(ExecNodes); scan_plan->exec_nodes->tableusagetype = TABLE_USAGE_TYPE_USER; - scan_plan->exec_nodes->baselocatortype = rel_loc_info->locatorType; + if (rel_loc_info) + scan_plan->exec_nodes->baselocatortype = rel_loc_info->locatorType; + else + scan_plan->exec_nodes->baselocatortype = '\0'; scan_plan->exec_nodes = GetRelationNodes(rel_loc_info, NULL, RELATION_ACCESS_READ); diff --git a/src/backend/pgxc/plan/planner.c b/src/backend/pgxc/plan/planner.c index 378d9b4..622834e 100644 --- a/src/backend/pgxc/plan/planner.c +++ b/src/backend/pgxc/plan/planner.c @@ -762,6 +762,9 @@ examine_conditions_walker(Node *expr_node, XCWalkerContext *context) RangeTblEntry *table = (RangeTblEntry *) linitial(context->query->rtable); node_cursor = step->cursor; rel_loc_info1 = GetRelationLocInfo(table->relid); + if (!rel_loc_info1) + return true; + context->query_step->exec_nodes = makeNode(ExecNodes); context->query_step->exec_nodes->tableusagetype = TABLE_USAGE_TYPE_USER; context->query_step->exec_nodes->baselocatortype = rel_loc_info1->locatorType; @@ -1121,6 +1124,9 @@ examine_conditions_walker(Node *expr_node, XCWalkerContext *context) if (!column_base2) return true; rel_loc_info2 = GetRelationLocInfo(column_base2->relid); + if (!rel_loc_info2) + return true; + /* get data struct about these two relations joining */ pgxc_join = find_or_create_pgxc_join(column_base->relid, column_base->relalias, diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c index 85f397d..78850bb 100644 --- a/src/backend/rewrite/rewriteHandler.c +++ b/src/backend/rewrite/rewriteHandler.c @@ -2309,6 +2309,9 @@ RewriteInsertStmt(Query *query, RangeTblEntry *values_rte) rte = (RangeTblEntry *) list_nth(query->rtable, query->resultRelation - 1); rte_loc_info = GetRelationLocInfo(rte->relid); + if (!rte_loc_info) + return NULL; + locatorType = rte_loc_info->locatorType; partColName = rte_loc_info->partAttrName; ----------------------------------------------------------------------- Summary of changes: src/backend/catalog/heap.c | 5 ++++- src/backend/optimizer/plan/createplan.c | 5 ++++- src/backend/pgxc/plan/planner.c | 6 ++++++ src/backend/rewrite/rewriteHandler.c | 3 +++ 4 files changed, 17 insertions(+), 2 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-08 08:10:47
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 60fd3944c0015203d62ae4bb49f209bc0a3b827b (commit) from 3af192ad45f2e21a74d032faa4612259606aa266 (commit) - Log ----------------------------------------------------------------- commit 60fd3944c0015203d62ae4bb49f209bc0a3b827b Author: Michael P <mic...@us...> Date: Tue Mar 8 17:09:38 2011 +0900 Block TEMP SEQUENCE and TABLESPACE Those features are not supported yet. diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c index 8646f9c..ee19184 100644 --- a/src/backend/commands/sequence.c +++ b/src/backend/commands/sequence.c @@ -146,6 +146,14 @@ DefineSequence(CreateSeqStmt *seq) init_params(seq->options, true, &new, &owned_by); #endif +#ifdef PGXC + if (seq->sequence->istemp) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("Postgres-XC does not support TEMPORARY SEQUENCE yet"), + errdetail("The feature is not currently supported"))); +#endif + /* * Create relation (and fill value[] and null[] for the tuple) */ diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index 3ff5ced..c278ea0 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -661,6 +661,12 @@ standard_ProcessUtility(Node *parsetree, break; case T_CreateTableSpaceStmt: +#ifdef PGXC + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("Postgres-XC does not support TABLESPACE yet"), + errdetail("The feature is not currently supported"))); +#endif PreventTransactionChain(isTopLevel, "CREATE TABLESPACE"); CreateTableSpace((CreateTableSpaceStmt *) parsetree); break; ----------------------------------------------------------------------- Summary of changes: src/backend/commands/sequence.c | 8 ++++++++ src/backend/tcop/utility.c | 6 ++++++ 2 files changed, 14 insertions(+), 0 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-08 05:16:26
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 3af192ad45f2e21a74d032faa4612259606aa266 (commit) from ab949a7cb237c6966a19204b23aea6c931928961 (commit) - Log ----------------------------------------------------------------- commit 3af192ad45f2e21a74d032faa4612259606aa266 Author: Michael P <mic...@us...> Date: Tue Mar 8 14:14:11 2011 +0900 Block FOREIGN constraint creation This prevents a crash in truncate test of pg_regress. Correct error messages for non-supported features. diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 822ca0b..30f5cd9 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -1585,6 +1585,12 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt, constraint->skip_validation = true; #ifdef PGXC + if (constraint->contype == CONSTR_FOREIGN) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("Postgres-XC does not support FOREIGN constraints yet"), + errdetail("The feature is not currently supported"))); + /* * Set fallback distribution column. * If not yet set, set it to first column in FK constraint diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index a48c4a3..3ff5ced 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -807,7 +807,8 @@ standard_ProcessUtility(Node *parsetree, #ifdef PGXC ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("PREPARE is not supported"))); + errmsg("Postgres-XC does not support PREPARE yet"), + errdetail("The feature is not currently supported"))); #endif CheckRestrictedOperation("PREPARE"); PrepareQuery((PrepareStmt *) parsetree, queryString); @@ -817,7 +818,8 @@ standard_ProcessUtility(Node *parsetree, #ifdef PGXC ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("EXECUTE is not supported"))); + errmsg("Postgres-XC does not support EXECUTE yet"), + errdetail("The feature is not currently supported"))); #endif ExecuteQuery((ExecuteStmt *) parsetree, queryString, params, dest, completionTag); @@ -1062,8 +1064,8 @@ standard_ProcessUtility(Node *parsetree, { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("PGXC does not support concurrent indexes"), - errdetail("The feature is not currently supported"))); + errmsg("PGXC does not support concurrent INDEX yet"), + errdetail("The feature is not currently supported"))); } #endif @@ -1311,7 +1313,8 @@ standard_ProcessUtility(Node *parsetree, /* Postgres-XC does not support yet triggers */ ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("TRIGGER is not supported"))); + errmsg("Postgres-XC does not support TRIGGER yet"), + errdetail("The feature is not currently supported"))); if (IS_PGXC_COORDINATOR) ExecUtilityStmtOnNodes(queryString, NULL, false, EXEC_ON_ALL_NODES); ----------------------------------------------------------------------- Summary of changes: src/backend/parser/parse_utilcmd.c | 6 ++++++ src/backend/tcop/utility.c | 13 ++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-08 03:58:22
|
Project "Postgres-XC". The branch, ha_support has been updated via c6be69cf56ee25852b90728f677b09b834e46fec (commit) from 6ee7a8fb4ca7ca60504b443da95c0c3314b1c88d (commit) - Log ----------------------------------------------------------------- commit c6be69cf56ee25852b90728f677b09b834e46fec Author: Michael P <mic...@us...> Date: Tue Mar 8 12:53:20 2011 +0900 Fix for 2PC data extension Node list was not set correctly, resulting in data inconsistency in this pg_prepared_xact() diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c index de766ff..d1df279 100644 --- a/src/backend/access/transam/twophase.c +++ b/src/backend/access/transam/twophase.c @@ -360,7 +360,7 @@ MarkAsPreparing(TransactionId xid, const char *gid, strcpy(gxact->gid, gid); #ifdef PGXC /* Add also the records associated to a PGXC 2PC */ - memcpy(gxact->nodelist, PGXC2PCData->nodelist, strlen(PGXC2PCData->nodelist)); + memcpy(gxact->nodelist, PGXC2PCData->nodelist, strlen(PGXC2PCData->nodelist) + 1); gxact->isimplicit = PGXC2PCData->isimplicit; gxact->isddl = PGXC2PCData->isddl; gxact->coordnum = PGXC2PCData->coordnum; ----------------------------------------------------------------------- Summary of changes: src/backend/access/transam/twophase.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-08 02:49:53
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via ab949a7cb237c6966a19204b23aea6c931928961 (commit) from 11b8a7940017006e07f7448c9a42e20b11655ba0 (commit) - Log ----------------------------------------------------------------- commit ab949a7cb237c6966a19204b23aea6c931928961 Author: Michael P <mic...@us...> Date: Tue Mar 8 11:47:58 2011 +0900 Partial fix for regression test temp TEMP tables are not supported yet by Postgre-XC. There is still a couple of issues remaining with whereami and whoami. diff --git a/src/test/regress/expected/temp_1.out b/src/test/regress/expected/temp_1.out new file mode 100644 index 0000000..b966fb3 --- /dev/null +++ b/src/test/regress/expected/temp_1.out @@ -0,0 +1,200 @@ +-- +-- TEMP +-- Test temp relations and indexes +-- +-- test temp table/index masking +CREATE TABLE temptest(col int); +CREATE INDEX i_temptest ON temptest(col); +CREATE TEMP TABLE temptest(tcol int); +ERROR: PG-XC does not yet support temporary tables +CREATE INDEX i_temptest ON temptest(tcol); +ERROR: column "tcol" does not exist +SELECT * FROM temptest; + col +----- +(0 rows) + +DROP INDEX i_temptest; +DROP TABLE temptest; +SELECT * FROM temptest; +ERROR: relation "temptest" does not exist +LINE 1: SELECT * FROM temptest; + ^ +DROP INDEX i_temptest; +ERROR: index "i_temptest" does not exist +DROP TABLE temptest; +ERROR: table "temptest" does not exist +-- test temp table selects +CREATE TABLE temptest(col int); +INSERT INTO temptest VALUES (1); +CREATE TEMP TABLE temptest(tcol float); +ERROR: PG-XC does not yet support temporary tables +INSERT INTO temptest VALUES (2.1); +SELECT * FROM temptest; + col +----- + 1 + 2 +(2 rows) + +DROP TABLE temptest; +SELECT * FROM temptest; +ERROR: relation "temptest" does not exist +LINE 1: SELECT * FROM temptest; + ^ +DROP TABLE temptest; +ERROR: table "temptest" does not exist +-- test temp table deletion +CREATE TEMP TABLE temptest(col int); +ERROR: PG-XC does not yet support temporary tables +\c +SELECT * FROM temptest; +ERROR: relation "temptest" does not exist +LINE 1: SELECT * FROM temptest; + ^ +-- Test ON COMMIT DELETE ROWS +CREATE TEMP TABLE temptest(col int) ON COMMIT DELETE ROWS; +ERROR: PG-XC does not yet support temporary tables +BEGIN; +INSERT INTO temptest VALUES (1); +ERROR: relation "temptest" does not exist +LINE 1: INSERT INTO temptest VALUES (1); + ^ +INSERT INTO temptest VALUES (2); +ERROR: current transaction is aborted, commands ignored until end of transaction block +SELECT * FROM temptest ORDER BY 1; +ERROR: current transaction is aborted, commands ignored until end of transaction block +COMMIT; +SELECT * FROM temptest; +ERROR: relation "temptest" does not exist +LINE 1: SELECT * FROM temptest; + ^ +DROP TABLE temptest; +ERROR: table "temptest" does not exist +BEGIN; +CREATE TEMP TABLE temptest(col) ON COMMIT DELETE ROWS AS SELECT 1; +ERROR: INTO clause not yet supported +SELECT * FROM temptest; +ERROR: current transaction is aborted, commands ignored until end of transaction block +COMMIT; +SELECT * FROM temptest; +ERROR: relation "temptest" does not exist +LINE 1: SELECT * FROM temptest; + ^ +DROP TABLE temptest; +ERROR: table "temptest" does not exist +-- Test ON COMMIT DROP +BEGIN; +CREATE TEMP TABLE temptest(col int) ON COMMIT DROP; +ERROR: PG-XC does not yet support temporary tables +INSERT INTO temptest VALUES (1); +ERROR: current transaction is aborted, commands ignored until end of transaction block +INSERT INTO temptest VALUES (2); +ERROR: current transaction is aborted, commands ignored until end of transaction block +SELECT * FROM temptest ORDER BY 1; +ERROR: current transaction is aborted, commands ignored until end of transaction block +COMMIT; +SELECT * FROM temptest; +ERROR: relation "temptest" does not exist +LINE 1: SELECT * FROM temptest; + ^ +BEGIN; +CREATE TEMP TABLE temptest(col) ON COMMIT DROP AS SELECT 1; +ERROR: INTO clause not yet supported +SELECT * FROM temptest; +ERROR: current transaction is aborted, commands ignored until end of transaction block +COMMIT; +SELECT * FROM temptest; +ERROR: relation "temptest" does not exist +LINE 1: SELECT * FROM temptest; + ^ +-- ON COMMIT is only allowed for TEMP +CREATE TABLE temptest(col int) ON COMMIT DELETE ROWS; +ERROR: ON COMMIT can only be used on temporary tables +CREATE TABLE temptest(col) ON COMMIT DELETE ROWS AS SELECT 1; +ERROR: INTO clause not yet supported +-- Test foreign keys +BEGIN; +CREATE TEMP TABLE temptest1(col int PRIMARY KEY); +ERROR: PG-XC does not yet support temporary tables +CREATE TEMP TABLE temptest2(col int REFERENCES temptest1) + ON COMMIT DELETE ROWS; +ERROR: current transaction is aborted, commands ignored until end of transaction block +INSERT INTO temptest1 VALUES (1); +ERROR: current transaction is aborted, commands ignored until end of transaction block +INSERT INTO temptest2 VALUES (1); +ERROR: current transaction is aborted, commands ignored until end of transaction block +COMMIT; +SELECT * FROM temptest1; +ERROR: relation "temptest1" does not exist +LINE 1: SELECT * FROM temptest1; + ^ +SELECT * FROM temptest2; +ERROR: relation "temptest2" does not exist +LINE 1: SELECT * FROM temptest2; + ^ +BEGIN; +CREATE TEMP TABLE temptest3(col int PRIMARY KEY) ON COMMIT DELETE ROWS; +ERROR: PG-XC does not yet support temporary tables +CREATE TEMP TABLE temptest4(col int REFERENCES temptest3); +ERROR: current transaction is aborted, commands ignored until end of transaction block +COMMIT; +-- Test manipulation of temp schema's placement in search path +create table public.whereami (f1 text); +insert into public.whereami values ('public'); +create temp table whereami (f1 text); +ERROR: PG-XC does not yet support temporary tables +insert into whereami values ('temp'); +create function public.whoami() returns text + as $$select 'public'::text$$ language sql; +create function pg_temp.whoami() returns text + as $$select 'temp'::text$$ language sql; +-- default should have pg_temp implicitly first, but only for tables +select * from whereami; + f1 +------ + temp +(1 row) + +select whoami(); + whoami +-------- + public +(1 row) + +-- can list temp first explicitly, but it still doesn't affect functions +set search_path = pg_temp, public; +select * from whereami; + f1 +------ + temp +(1 row) + +select whoami(); + whoami +-------- + public +(1 row) + +-- or put it last for security +set search_path = public, pg_temp; +select * from whereami; + f1 +-------- + public +(1 row) + +select whoami(); + whoami +-------- + public +(1 row) + +-- you can invoke a temp function explicitly, though +select pg_temp.whoami(); + whoami +-------- + temp +(1 row) + +drop table public.whereami; ----------------------------------------------------------------------- Summary of changes: src/test/regress/expected/{temp.out => temp_1.out} | 113 ++++++++++---------- 1 files changed, 55 insertions(+), 58 deletions(-) copy src/test/regress/expected/{temp.out => temp_1.out} (59%) hooks/post-receive -- Postgres-XC |