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-29 12:03:24
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 82c7049c243ba0849d93b6f73e1b4b96a64f4d9c (commit) from f61d2df4e202e715877b676bbb194552588b43bd (commit) - Log ----------------------------------------------------------------- commit 82c7049c243ba0849d93b6f73e1b4b96a64f4d9c Author: Michael P <mic...@us...> Date: Tue Mar 29 21:01:16 2011 +0900 Fix a cache leak WARNING with system cache This was happening because of commit 76f1d9cde238be026007d00a6af192b7f7ac4ce5 because data cached was not released. diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index ad8c568..3458247 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -22,7 +22,6 @@ #include "utils/lsyscache.h" #ifdef PGXC #include "pgxc/pgxc.h" -#include "parser/parse_type.h" #endif static void printtup_startup(DestReceiver *self, int operation, @@ -201,7 +200,7 @@ SendRowDescriptionMessage(TupleDesc typeinfo, List *targetlist, int16 *formats) if (IS_PGXC_DATANODE && IsConnFromCoord()) { char *typename; - typename = typeTypeName(typeidType(atttypid)); + typename = get_typename(atttypid); pq_sendstring(&buf, typename); } #endif diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c index 8cac03b..3cd7f40 100644 --- a/src/backend/utils/cache/lsyscache.c +++ b/src/backend/utils/cache/lsyscache.c @@ -2017,6 +2017,30 @@ getBaseTypeAndTypmod(Oid typid, int32 *typmod) return typid; } +#ifdef PGXC +/* + * Get type name for given type ID + */ +char * +get_typename(Oid typid) +{ + HeapTuple tuple; + Form_pg_type typeForm; + char *result; + + tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); + + if (!HeapTupleIsValid(tuple)) + elog(ERROR, "cache lookup failed for type %u", typid); + + typeForm = (Form_pg_type) GETSTRUCT(tuple); + result = pstrdup(NameStr(typeForm->typname)); + ReleaseSysCache(tuple); + + return result; +} +#endif + /* * get_typavgwidth * diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h index 4c88b59..7f60371 100644 --- a/src/include/utils/lsyscache.h +++ b/src/include/utils/lsyscache.h @@ -127,6 +127,9 @@ extern void getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena); extern Oid get_typmodin(Oid typid); extern Oid getBaseType(Oid typid); extern Oid getBaseTypeAndTypmod(Oid typid, int32 *typmod); +#ifdef PGXC +extern char *get_typename(Oid typid); +#endif extern int32 get_typavgwidth(Oid typid, int32 typmod); extern int32 get_attavgwidth(Oid relid, AttrNumber attnum); extern bool get_attstatsslot(HeapTuple statstuple, ----------------------------------------------------------------------- Summary of changes: src/backend/access/common/printtup.c | 3 +-- src/backend/utils/cache/lsyscache.c | 24 ++++++++++++++++++++++++ src/include/utils/lsyscache.h | 3 +++ 3 files changed, 28 insertions(+), 2 deletions(-) hooks/post-receive -- Postgres-XC |
From: Abbas B. <ga...@us...> - 2011-03-28 17:00:29
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via f61d2df4e202e715877b676bbb194552588b43bd (commit) via 09be104bfe29525f3423b3b07a9f88b943c8845e (commit) from 75b80f6575e6c29dc07d2e8cd803a8c2cb309bde (commit) - Log ----------------------------------------------------------------- commit f61d2df4e202e715877b676bbb194552588b43bd Merge: 09be104 75b80f6 Author: Abbas <abb...@en...> Date: Mon Mar 28 21:58:20 2011 +0500 Merge branch 'merge_postgres_9_0_3' of ssh://postgres-xc.git.sourceforge.net/gitroot/postgres-xc/postgres-xc into merge_postgres_9_0_3 commit 09be104bfe29525f3423b3b07a9f88b943c8845e Author: Abbas <abb...@en...> Date: Mon Mar 28 21:49:14 2011 +0500 This patch fixes the problem in XC that error detail was not being handled. This would fix bug id 3220325 and numeric test case would now pass. diff --git a/src/backend/pgxc/pool/execRemote.c b/src/backend/pgxc/pool/execRemote.c index 95f23f3..7c9ec5b 100644 --- a/src/backend/pgxc/pool/execRemote.c +++ b/src/backend/pgxc/pool/execRemote.c @@ -213,6 +213,7 @@ CreateResponseCombiner(int node_count, CombineType combine_type) combiner->copy_in_count = 0; combiner->copy_out_count = 0; combiner->errorMessage = NULL; + combiner->errorDetail = NULL; combiner->query_Done = false; combiner->currentRow.msg = NULL; combiner->currentRow.msglen = 0; @@ -812,6 +813,11 @@ HandleError(RemoteQueryState *combiner, char *msg_body, size_t len) memcpy(combiner->errorCode, code, 5); } + if (!combiner->errorDetail && detail != NULL) + { + combiner->errorDetail = pstrdup(detail); + } + /* * If data node have sent ErrorResponse it will never send CommandComplete. * Increment the counter to prevent endless waiting for it. @@ -950,6 +956,8 @@ CloseCombiner(RemoteQueryState *combiner) FreeTupleDesc(combiner->tuple_desc); if (combiner->errorMessage) pfree(combiner->errorMessage); + if (combiner->errorDetail) + pfree(combiner->errorDetail); if (combiner->cursor_connections) pfree(combiner->cursor_connections); if (combiner->tapenodes) @@ -994,6 +1002,8 @@ ValidateAndResetCombiner(RemoteQueryState *combiner) list_free_deep(combiner->rowBuffer); if (combiner->errorMessage) pfree(combiner->errorMessage); + if (combiner->errorDetail) + pfree(combiner->errorDetail); if (combiner->tapenodes) pfree(combiner->tapenodes); @@ -1006,6 +1016,7 @@ ValidateAndResetCombiner(RemoteQueryState *combiner) combiner->copy_in_count = 0; combiner->copy_out_count = 0; combiner->errorMessage = NULL; + combiner->errorDetail = NULL; combiner->query_Done = false; combiner->currentRow.msg = NULL; combiner->currentRow.msglen = 0; @@ -3344,9 +3355,14 @@ do_query(RemoteQueryState *node) if (node->errorMessage) { char *code = node->errorCode; - ereport(ERROR, - (errcode(MAKE_SQLSTATE(code[0], code[1], code[2], code[3], code[4])), - errmsg("%s", node->errorMessage))); + if (node->errorDetail != NULL) + ereport(ERROR, + (errcode(MAKE_SQLSTATE(code[0], code[1], code[2], code[3], code[4])), + errmsg("%s", node->errorMessage), errdetail("%s", node->errorDetail) )); + else + ereport(ERROR, + (errcode(MAKE_SQLSTATE(code[0], code[1], code[2], code[3], code[4])), + errmsg("%s", node->errorMessage))); } } @@ -3712,9 +3728,14 @@ handle_results: if (node->errorMessage) { char *code = node->errorCode; - ereport(ERROR, - (errcode(MAKE_SQLSTATE(code[0], code[1], code[2], code[3], code[4])), - errmsg("%s", node->errorMessage))); + if (node->errorDetail != NULL) + ereport(ERROR, + (errcode(MAKE_SQLSTATE(code[0], code[1], code[2], code[3], code[4])), + errmsg("%s", node->errorMessage), errdetail("%s", node->errorDetail) )); + else + ereport(ERROR, + (errcode(MAKE_SQLSTATE(code[0], code[1], code[2], code[3], code[4])), + errmsg("%s", node->errorMessage))); } /* @@ -4311,9 +4332,14 @@ ExecRemoteUtility(RemoteQuery *node) if (remotestate->errorMessage) { char *code = remotestate->errorCode; - ereport(ERROR, - (errcode(MAKE_SQLSTATE(code[0], code[1], code[2], code[3], code[4])), - errmsg("%s", remotestate->errorMessage))); + if (remotestate->errorDetail != NULL) + ereport(ERROR, + (errcode(MAKE_SQLSTATE(code[0], code[1], code[2], code[3], code[4])), + errmsg("%s", remotestate->errorMessage), errdetail("%s", remotestate->errorDetail) )); + else + ereport(ERROR, + (errcode(MAKE_SQLSTATE(code[0], code[1], code[2], code[3], code[4])), + errmsg("%s", remotestate->errorMessage))); } } diff --git a/src/include/pgxc/execRemote.h b/src/include/pgxc/execRemote.h index 2b8b8ce..1113468 100644 --- a/src/include/pgxc/execRemote.h +++ b/src/include/pgxc/execRemote.h @@ -82,6 +82,7 @@ typedef struct RemoteQueryState int copy_out_count; /* count of received CopyOut messages */ char errorCode[5]; /* error code to send back to client */ char *errorMessage; /* error message to send back to client */ + char *errorDetail; /* error detail to send back to client */ bool query_Done; /* query has been sent down to data nodes */ RemoteDataRowData currentRow; /* next data ro to be wrapped into a tuple */ /* TODO use a tuplestore as a rowbuffer */ diff --git a/src/test/regress/expected/numeric_1.out b/src/test/regress/expected/numeric_1.out index 89c19c9..b93d694 100644 --- a/src/test/regress/expected/numeric_1.out +++ b/src/test/regress/expected/numeric_1.out @@ -688,10 +688,12 @@ 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 +DETAIL: A field with precision 4, scale 4 must round to an absolute value less than 1. 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 +DETAIL: A field with precision 4, scale 4 must round to an absolute value less than 1. INSERT INTO fract_only VALUES (7, '0.00001'); INSERT INTO fract_only VALUES (8, '0.00017'); SELECT * FROM fract_only ORDER BY id; @@ -1035,16 +1037,16 @@ SELECT '' AS to_char_15, to_char(val, 'FM9999999990999999.099999999999999') FRO SELECT '' AS to_char_16, to_char(val, 'L9999999999999999.099999999999999') FROM num_data ORDER BY val; to_char_16 | to_char ------------+------------------------------------ - | $ -83028485.000000000000000 + | -83028485.000000000000000 | -34338492.215397047000000 - | $ -24926804.045047420000000 - | $ .000000000000000 - | $ .000000000000000 + | -24926804.045047420000000 + | .000000000000000 + | .000000000000000 | 4.310000000000000 | 16397.038491000000000 | 74881.000000000000000 - | $ 93901.577630260000000 - | $ 7799461.411900000000000 + | 93901.577630260000000 + | 7799461.411900000000000 (10 rows) SELECT '' AS to_char_17, to_char(val, 'FM9999999999999999.99999999999999') FROM num_data ORDER BY val; @@ -1137,6 +1139,21 @@ SELECT '' AS to_char_22, to_char(val, 'FM9999999999999999.999999999999999') FROM | 7799461.4119 (10 rows) +SELECT '' AS to_char_23, to_char(val, '9.999EEEE') FROM num_data ORDER BY val; + to_char_23 | to_char +------------+------------ + | -8.303e+07 + | -3.434e+07 + | -2.493e+07 + | 0.000e+00 + | 0.000e+00 + | 4.310e+00 + | 1.640e+04 + | 7.488e+04 + | 9.390e+04 + | 7.799e+06 +(10 rows) + -- TO_NUMBER() -- SELECT '' AS to_number_1, to_number('-34,338,492', '99G999G999'); diff --git a/src/test/regress/sql/numeric.sql b/src/test/regress/sql/numeric.sql index 83ee939..1ab688c 100644 --- a/src/test/regress/sql/numeric.sql +++ b/src/test/regress/sql/numeric.sql @@ -762,6 +762,7 @@ 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 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; SELECT '' AS to_char_21, to_char(val, '999999SG9999999999') FROM num_data ORDER BY val; SELECT '' AS to_char_22, to_char(val, 'FM9999999999999999.999999999999999') FROM num_data ORDER BY val; +SELECT '' AS to_char_23, to_char(val, '9.999EEEE') FROM num_data ORDER BY val; -- TO_NUMBER() -- ----------------------------------------------------------------------- Summary of changes: src/backend/pgxc/pool/execRemote.c | 44 ++++++++++++++++++++++++------ src/include/pgxc/execRemote.h | 1 + src/test/regress/expected/numeric_1.out | 29 ++++++++++++++++---- src/test/regress/sql/numeric.sql | 1 + 4 files changed, 60 insertions(+), 15 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-28 16:41:26
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 75b80f6575e6c29dc07d2e8cd803a8c2cb309bde (commit) from 6654fe0c6fac62e0351b3a409d26861789e9906b (commit) - Log ----------------------------------------------------------------- commit 75b80f6575e6c29dc07d2e8cd803a8c2cb309bde Author: Michael P <mic...@us...> Date: Tue Mar 29 00:41:24 2011 +0900 Fix for VIEW and SEQUENCE Views were only created on local Coordinator but they need to be created on all Coordinators. DROP VIEW was made on all the nodes, but now it is made only on Coordinator. ALTER SEQUENCE/VIEW ... SET SCHEMA ... ALTER SEQUENCE/VIEW ... RENAME TO ... are also correctly fixed. There was an issue with sequence renaming: CREATE SEQUENCE foo; ALTER SEQUENCE foo RENAME TO foobar; CREATE SEQUENCE foo; -- ERROR Error was caused by sequence with former name which was not correctly removed on GTM. diff --git a/src/backend/access/transam/gtm.c b/src/backend/access/transam/gtm.c index a9bf1d6..e9f0229 100644 --- a/src/backend/access/transam/gtm.c +++ b/src/backend/access/transam/gtm.c @@ -422,7 +422,7 @@ RenameSequenceGTM(char *seqname, const char *newseqname) seqkey.gsk_keylen = strlen(seqname); seqkey.gsk_key = seqname; newseqkey.gsk_keylen = strlen(newseqname); - newseqkey.gsk_key = (char *)newseqname; + newseqkey.gsk_key = (char *) newseqname; return conn ? rename_sequence(conn, &seqkey, &newseqkey) : -1; } diff --git a/src/backend/commands/schemacmds.c b/src/backend/commands/schemacmds.c index 09ae5c3..4496bcd 100644 --- a/src/backend/commands/schemacmds.c +++ b/src/backend/commands/schemacmds.c @@ -33,6 +33,7 @@ #ifdef PGXC #include "pgxc/pgxc.h" +#include "pgxc/planner.h" #endif static void AlterSchemaOwner_internal(HeapTuple tup, Relation rel, Oid newOwnerId); @@ -131,7 +132,7 @@ CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString) * Add a RemoteQuery node for a query at top level on a remote Coordinator */ if (is_top_level) - parsetree_list = AddRemoteQueryNode(parsetree_list, queryString); + parsetree_list = AddRemoteQueryNode(parsetree_list, queryString, EXEC_ON_ALL_NODES); #endif /* diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c index 8a921f5..aceee06 100644 --- a/src/backend/commands/sequence.c +++ b/src/backend/commands/sequence.c @@ -1448,7 +1448,7 @@ GetGlobalSeqName(Relation seqrel, const char *new_seqname, const char *new_schem /* Get all the necessary relation names */ dbname = get_database_name(seqrel->rd_node.dbNode); - + if (new_seqname) relname = (char *) new_seqname; else diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 18e9358..67a14c8 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -80,6 +80,7 @@ #ifdef PGXC #include "pgxc/pgxc.h" #include "access/gtm.h" +#include "commands/sequence.h" #endif /* @@ -7962,6 +7963,26 @@ AlterTableNamespace(RangeVar *relation, const char *newschema, heap_close(classRel, RowExclusiveLock); +#ifdef PGXC + /* Rename also sequence on GTM for a sequence */ + if (IS_PGXC_COORDINATOR && + !IsConnFromCoord() && + rel->rd_rel->relkind == RELKIND_SEQUENCE) + { + char *seqname = GetGlobalSeqName(rel, NULL, NULL); + char *newseqname = GetGlobalSeqName(rel, NULL, newschema); + + /* We also need to rename it on the GTM */ + if (RenameSequenceGTM(seqname, newseqname) < 0) + ereport(ERROR, + (errcode(ERRCODE_CONNECTION_FAILURE), + errmsg("GTM error, could not rename sequence"))); + + pfree(seqname); + pfree(newseqname); + } +#endif + /* close rel, but keep lock until commit */ relation_close(rel, NoLock); } diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 21b5cfd..9b48756 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -2633,30 +2633,4 @@ 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/pgxc/plan/planner.c b/src/backend/pgxc/plan/planner.c index 90031fa..45c453a 100644 --- a/src/backend/pgxc/plan/planner.c +++ b/src/backend/pgxc/plan/planner.c @@ -33,6 +33,7 @@ #include "parser/parse_agg.h" #include "parser/parse_coerce.h" #include "pgxc/execRemote.h" +#include "pgxc/pgxc.h" #include "pgxc/locator.h" #include "pgxc/planner.h" #include "tcop/pquery.h" @@ -3353,3 +3354,27 @@ GetHashExecNodes(RelationLocInfo *rel_loc_info, ExecNodes **exec_nodes, const Ex } +/* + * 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, RemoteQueryExecType remoteExecType) +{ + 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; + step->exec_type = remoteExecType; + result = lappend(result, step); + } + + return result; +} diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index d06fdb2..284a52c 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -615,7 +615,7 @@ standard_ProcessUtility(Node *parsetree, * Add a RemoteQuery node for a query at top level on a remote Coordinator */ if (isTopLevel) - stmts = AddRemoteQueryNode(stmts, queryString); + stmts = AddRemoteQueryNode(stmts, queryString, EXEC_ON_ALL_NODES); #endif /* ... and do it */ @@ -773,14 +773,14 @@ standard_ProcessUtility(Node *parsetree, } #ifdef PGXC /* - * PGXCTODO - * We may need to check details of the object being dropped and + * We need to check details of the object being dropped and * run command on correct nodes */ - if (IS_PGXC_COORDINATOR) + if (IS_PGXC_COORDINATOR && !IsConnFromCoord()) { - /* Sequence exists only on Coordinators */ - if (stmt->removeType == OBJECT_SEQUENCE) + /* Sequence and views exists only on Coordinators */ + if (stmt->removeType == OBJECT_SEQUENCE || + stmt->removeType == OBJECT_VIEW) ExecUtilityStmtOnNodes(queryString, NULL, false, EXEC_ON_COORDS); else ExecUtilityStmtOnNodes(queryString, NULL, false, EXEC_ON_ALL_NODES); @@ -854,7 +854,8 @@ standard_ProcessUtility(Node *parsetree, RemoteQueryExecType remoteExecType = EXEC_ON_ALL_NODES; RenameStmt *stmt = (RenameStmt *) parsetree; - if (stmt->renameType == OBJECT_SEQUENCE) + if (stmt->renameType == OBJECT_SEQUENCE || + stmt->renameType == OBJECT_VIEW) remoteExecType = EXEC_ON_COORDS; else if (stmt->renameType == OBJECT_TABLE) { @@ -872,8 +873,23 @@ standard_ProcessUtility(Node *parsetree, case T_AlterObjectSchemaStmt: #ifdef PGXC - if (IS_PGXC_COORDINATOR) - ExecUtilityStmtOnNodes(queryString, NULL, false, EXEC_ON_ALL_NODES); + if (IS_PGXC_COORDINATOR && !IsConnFromCoord()) + { + RemoteQueryExecType remoteExecType = EXEC_ON_ALL_NODES; + AlterObjectSchemaStmt *stmt = (AlterObjectSchemaStmt *) parsetree; + + if (stmt->objectType == OBJECT_SEQUENCE || + stmt->objectType == OBJECT_VIEW) + remoteExecType = EXEC_ON_COORDS; + else if (stmt->objectType == OBJECT_TABLE) + { + Oid relid = RangeVarGetRelid(stmt->relation, false); + + if (get_rel_relkind(relid) == RELKIND_SEQUENCE) + remoteExecType = EXEC_ON_COORDS; + } + ExecUtilityStmtOnNodes(queryString, NULL, false, remoteExecType); + } #endif ExecAlterObjectSchemaStmt((AlterObjectSchemaStmt *) parsetree); break; @@ -895,7 +911,23 @@ standard_ProcessUtility(Node *parsetree, * Add a RemoteQuery node for a query at top level on a remote Coordinator */ if (isTopLevel) - stmts = AddRemoteQueryNode(stmts, queryString); + { + RemoteQueryExecType remoteExecType = EXEC_ON_ALL_NODES; + AlterTableStmt *stmt = (AlterTableStmt *) parsetree; + + if (stmt->relkind == OBJECT_VIEW || + stmt->relkind == OBJECT_SEQUENCE) + remoteExecType = EXEC_ON_COORDS; + else if (stmt->relkind == OBJECT_TABLE) + { + Oid relid = RangeVarGetRelid(stmt->relation, false); + + if (get_rel_relkind(relid) == RELKIND_SEQUENCE) + remoteExecType = EXEC_ON_COORDS; + } + + stmts = AddRemoteQueryNode(stmts, queryString, remoteExecType); + } #endif /* ... and do it */ @@ -1057,6 +1089,10 @@ standard_ProcessUtility(Node *parsetree, case T_ViewStmt: /* CREATE VIEW */ DefineView((ViewStmt *) parsetree, queryString); +#ifdef PGXC + if (IS_PGXC_COORDINATOR) + ExecUtilityStmtOnNodes(queryString, NULL, false, EXEC_ON_COORDS); +#endif break; case T_CreateFunctionStmt: /* CREATE FUNCTION */ diff --git a/src/gtm/Makefile.global b/src/gtm/Makefile.global index bfc052f..684690b 100644 --- a/src/gtm/Makefile.global +++ b/src/gtm/Makefile.global @@ -29,7 +29,7 @@ enable_shared = yes # Compilers CPP = gcc -E -CPPFLAGS = -D_GNU_SOURCE +CPPFLAGS = -g -D_GNU_SOURCE override CPPFLAGS := -I$(top_srcdir)/include $(CPPFLAGS) diff --git a/src/gtm/main/gtm_seq.c b/src/gtm/main/gtm_seq.c index 8c15fe9..f6c4a21 100644 --- a/src/gtm/main/gtm_seq.c +++ b/src/gtm/main/gtm_seq.c @@ -636,6 +636,8 @@ GTM_SeqRename(GTM_SequenceKey seqkey, GTM_SequenceKey newseqkey) /* Release first the structure as it has been taken previously */ seq_release_seqinfo(seqinfo); + /* Close sequence properly, full name is here */ + seqkey->gsk_type = GTM_SEQ_FULL_NAME; /* Then close properly the old sequence */ GTM_SeqClose(seqkey); return errcode; diff --git a/src/include/parser/parse_utilcmd.h b/src/include/parser/parse_utilcmd.h index 256c583..3f9b8f9 100644 --- a/src/include/parser/parse_utilcmd.h +++ b/src/include/parser/parse_utilcmd.h @@ -27,7 +27,6 @@ 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 */ diff --git a/src/include/pgxc/planner.h b/src/include/pgxc/planner.h index 4e4cd62..b69f940 100644 --- a/src/include/pgxc/planner.h +++ b/src/include/pgxc/planner.h @@ -210,4 +210,6 @@ extern bool is_immutable_func(Oid funcid); extern bool IsJoinReducible(RemoteQuery *innernode, RemoteQuery *outernode, List *rtable_list, JoinPath *join_path, JoinReduceInfo *join_info); +extern List *AddRemoteQueryNode(List *stmts, const char *queryString, RemoteQueryExecType remoteExecType); + #endif /* PGXCPLANNER_H */ diff --git a/src/test/regress/expected/privileges_1.out b/src/test/regress/expected/privileges_1.out index 90043e4..94b9267 100644 --- a/src/test/regress/expected/privileges_1.out +++ b/src/test/regress/expected/privileges_1.out @@ -1226,29 +1226,16 @@ ERROR: function testfunc2(integer) does not exist DROP FUNCTION testfunc4(boolean); ERROR: function testfunc4(boolean) does not exist DROP VIEW atestv1; -ERROR: view "atestv1" does not exist DROP VIEW atestv2; -ERROR: view "atestv2" does not exist -- this should cascade to drop atestv4 DROP VIEW atestv3 CASCADE; NOTICE: drop cascades to view atestv4 -ERROR: view "atestv3" does not exist -- this should complain "does not exist" DROP VIEW atestv4; ERROR: view "atestv4" does not exist DROP TABLE atest1; -ERROR: cannot drop table atest1 because other objects depend on it -DETAIL: view atestv1 depends on table atest1 -HINT: Use DROP ... CASCADE to drop the dependent objects too. DROP TABLE atest2; -ERROR: cannot drop table atest2 because other objects depend on it -DETAIL: view atestv2 depends on table atest2 -HINT: Use DROP ... CASCADE to drop the dependent objects too. DROP TABLE atest3; -ERROR: cannot drop table atest3 because other objects depend on it -DETAIL: view atestv3 depends on table atest3 -view atestv4 depends on view atestv3 -HINT: Use DROP ... CASCADE to drop the dependent objects too. DROP TABLE atest4; DROP TABLE atest5; DROP TABLE atest6; @@ -1268,43 +1255,13 @@ SELECT lo_unlink(oid) FROM pg_largeobject_metadata; DROP GROUP regressgroup1; DROP GROUP regressgroup2; -ERROR: role "regressgroup2" cannot be dropped because some objects depend on it -DETAIL: privileges for table atest3 -- these are needed to clean up permissions REVOKE USAGE ON LANGUAGE sql FROM regressuser1; DROP OWNED BY regressuser1; -ERROR: cannot drop desired object(s) because other objects depend on them -DETAIL: view atestv1 depends on table atest1 -view atestv2 depends on table atest2 -HINT: Use DROP ... CASCADE to drop the dependent objects too. DROP USER regressuser1; -ERROR: role "regressuser1" cannot be dropped because some objects depend on it -DETAIL: owner of default privileges on new functions belonging to role regressuser1 -owner of table atest2 -owner of table atest1 DROP USER regressuser2; -ERROR: role "regressuser2" cannot be dropped because some objects depend on it -DETAIL: privileges for view atestv4 -privileges for view atestv2 -privileges for table atest2 -privileges for table atest1 DROP USER regressuser3; -ERROR: role "regressuser3" cannot be dropped because some objects depend on it -DETAIL: owner of view atestv3 -owner of view atestv2 -owner of view atestv1 -owner of table atest3 -privileges for table atest2 -privileges for table atest1 DROP USER regressuser4; -ERROR: role "regressuser4" cannot be dropped because some objects depend on it -DETAIL: owner of view atestv4 -privileges for view atestv3 -privileges for view atestv1 -privileges for table atest2 -privileges for table atest1 DROP USER regressuser5; -ERROR: role "regressuser5" cannot be dropped because some objects depend on it -DETAIL: privileges for table atest2 DROP USER regressuser6; ERROR: role "regressuser6" does not exist ----------------------------------------------------------------------- Summary of changes: src/backend/access/transam/gtm.c | 2 +- src/backend/commands/schemacmds.c | 3 +- src/backend/commands/sequence.c | 2 +- src/backend/commands/tablecmds.c | 21 ++++++++++ src/backend/parser/parse_utilcmd.c | 26 ------------- src/backend/pgxc/plan/planner.c | 25 ++++++++++++ src/backend/tcop/utility.c | 56 +++++++++++++++++++++++----- src/gtm/Makefile.global | 2 +- src/gtm/main/gtm_seq.c | 2 + src/include/parser/parse_utilcmd.h | 1 - src/include/pgxc/planner.h | 2 + src/test/regress/expected/privileges_1.out | 43 --------------------- 12 files changed, 101 insertions(+), 84 deletions(-) hooks/post-receive -- Postgres-XC |
From: Abbas B. <ga...@us...> - 2011-03-28 15:00:53
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 6654fe0c6fac62e0351b3a409d26861789e9906b (commit) from 4f1d506fd83393fbbe98797fa49e862b5b17f19e (commit) - Log ----------------------------------------------------------------- commit 6654fe0c6fac62e0351b3a409d26861789e9906b Author: Abbas <abb...@en...> Date: Mon Mar 28 19:49:56 2011 +0500 This patch fixes a test case in strings.sql SELECT CAST(f1 as text) AS "f2" FROM CHAR_TBL ORDER BY f1 was reporting ERROR: ORDER BY "f1" is ambiguous The problem was in the function reconstruct_step_query. The function was reconstructing the query to look like SELECT (f1)::text, f1 FROM CHAR_TBL ORDER BY f1 and when this query was being sent to the data node, it was complaining. The solution adopted in this patch is to add column alias (if any) while reconstructing the query. Some cosmetic changes were also required for the strings test to pass. diff --git a/src/backend/pgxc/plan/planner.c b/src/backend/pgxc/plan/planner.c index e4d13cb..90031fa 100644 --- a/src/backend/pgxc/plan/planner.c +++ b/src/backend/pgxc/plan/planner.c @@ -2257,6 +2257,9 @@ reconstruct_step_query(List *rtable, bool has_order_by, List *extra_sort, appendStringInfo(buf, ", "); appendStringInfoString(buf, exprstr); + + if (tle->resname != NULL) + appendStringInfo(buf, " AS %s", quote_identifier(tle->resname)); } /* diff --git a/src/test/regress/expected/strings.out b/src/test/regress/expected/strings.out index 140c677..4773327 100644 --- a/src/test/regress/expected/strings.out +++ b/src/test/regress/expected/strings.out @@ -996,7 +996,7 @@ SELECT 'Hawkeye' NOT ILIKE 'h%' AS "false"; (1 row) -- --- test %/_ combination cases, cf bug #4821 +-- test %/_ combination cases, cf bugs #4821 and #5478 -- SELECT 'foo' LIKE '_%' as t, 'f' LIKE '_%' as t, '' LIKE '_%' as f; t | t | f diff --git a/src/test/regress/expected/strings.out b/src/test/regress/expected/strings_1.out similarity index 99% copy from src/test/regress/expected/strings.out copy to src/test/regress/expected/strings_1.out index 140c677..2bbdf50 100644 --- a/src/test/regress/expected/strings.out +++ b/src/test/regress/expected/strings_1.out @@ -996,7 +996,7 @@ SELECT 'Hawkeye' NOT ILIKE 'h%' AS "false"; (1 row) -- --- test %/_ combination cases, cf bug #4821 +-- test %/_ combination cases, cf bugs #4821 and #5478 -- SELECT 'foo' LIKE '_%' as t, 'f' LIKE '_%' as t, '' LIKE '_%' as f; t | t | f @@ -1128,12 +1128,12 @@ insert into toasttest values(decode(repeat('1234567890',10000),'escape')); -- If the starting position is zero or less, then return from the start of the string -- adjusting the length to be consistent with the "negative start" per SQL92. SELECT substr(f1, -1, 5) from toasttest; - substr --------- - 123 - 123 - 123 - 123 + substr +---------- + \x313233 + \x313233 + \x313233 + \x313233 (4 rows) -- If the length is less than zero, an ERROR is thrown. @@ -1142,23 +1142,23 @@ ERROR: negative substring length not allowed -- If no third argument (length) is provided, the length to the end of the -- string is assumed. SELECT substr(f1, 99995) from toasttest; - substr --------- - 567890 - 567890 - 567890 - 567890 + substr +---------------- + \x353637383930 + \x353637383930 + \x353637383930 + \x353637383930 (4 rows) -- If start plus length is > string length, the result is truncated to -- string length SELECT substr(f1, 99995, 10) from toasttest; - substr --------- - 567890 - 567890 - 567890 - 567890 + substr +---------------- + \x353637383930 + \x353637383930 + \x353637383930 + \x353637383930 (4 rows) DROP TABLE toasttest; ----------------------------------------------------------------------- Summary of changes: src/backend/pgxc/plan/planner.c | 3 ++ src/test/regress/expected/strings.out | 2 +- .../expected/{strings.out => strings_1.out} | 38 ++++++++++---------- 3 files changed, 23 insertions(+), 20 deletions(-) copy src/test/regress/expected/{strings.out => strings_1.out} (99%) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-25 17:11:16
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 4f1d506fd83393fbbe98797fa49e862b5b17f19e (commit) from 796bf6e4b113d356b7d725daa71d62835faf9c68 (commit) - Log ----------------------------------------------------------------- commit 4f1d506fd83393fbbe98797fa49e862b5b17f19e Author: Michael P <mic...@us...> Date: Sat Mar 26 02:09:57 2011 +0900 Fix for regression test privileges Postgres-XC does not support yet TEMP tables and non-immutable functions, so this output is correct. diff --git a/src/test/regress/expected/privileges_1.out b/src/test/regress/expected/privileges_1.out new file mode 100644 index 0000000..90043e4 --- /dev/null +++ b/src/test/regress/expected/privileges_1.out @@ -0,0 +1,1310 @@ +-- +-- Test access privileges +-- +-- Clean up in case a prior regression run failed +-- Suppress NOTICE messages when users/groups don't exist +SET client_min_messages TO 'warning'; +DROP ROLE IF EXISTS regressgroup1; +DROP ROLE IF EXISTS regressgroup2; +DROP ROLE IF EXISTS regressuser1; +DROP ROLE IF EXISTS regressuser2; +DROP ROLE IF EXISTS regressuser3; +DROP ROLE IF EXISTS regressuser4; +DROP ROLE IF EXISTS regressuser5; +DROP ROLE IF EXISTS regressuser6; +SELECT lo_unlink(oid) FROM pg_largeobject_metadata; + lo_unlink +----------- +(0 rows) + +RESET client_min_messages; +-- test proper begins here +CREATE USER regressuser1; +CREATE USER regressuser2; +CREATE USER regressuser3; +CREATE USER regressuser4; +CREATE USER regressuser5; +CREATE USER regressuser5; -- duplicate +ERROR: role "regressuser5" already exists +CREATE GROUP regressgroup1; +CREATE GROUP regressgroup2 WITH USER regressuser1, regressuser2; +ALTER GROUP regressgroup1 ADD USER regressuser4; +ALTER GROUP regressgroup2 ADD USER regressuser2; -- duplicate +NOTICE: role "regressuser2" is already a member of role "regressgroup2" +ALTER GROUP regressgroup2 DROP USER regressuser2; +ALTER GROUP regressgroup2 ADD USER regressuser4; +-- test owner privileges +SET SESSION AUTHORIZATION regressuser1; +SELECT session_user, current_user; + session_user | current_user +--------------+-------------- + regressuser1 | regressuser1 +(1 row) + +CREATE TABLE atest1 ( a int, b text ); +SELECT * FROM atest1; + a | b +---+--- +(0 rows) + +INSERT INTO atest1 VALUES (1, 'one'); +DELETE FROM atest1; +UPDATE atest1 SET a = 1 WHERE b = 'blech'; +ERROR: Partition column can't be updated in current version +TRUNCATE atest1; +BEGIN; +LOCK atest1 IN ACCESS EXCLUSIVE MODE; +COMMIT; +REVOKE ALL ON atest1 FROM PUBLIC; +SELECT * FROM atest1; + a | b +---+--- +(0 rows) + +GRANT ALL ON atest1 TO regressuser2; +GRANT SELECT ON atest1 TO regressuser3, regressuser4; +SELECT * FROM atest1; + a | b +---+--- +(0 rows) + +CREATE TABLE atest2 (col1 varchar(10), col2 boolean); +GRANT SELECT ON atest2 TO regressuser2; +GRANT UPDATE ON atest2 TO regressuser3; +GRANT INSERT ON atest2 TO regressuser4; +GRANT TRUNCATE ON atest2 TO regressuser5; +SET SESSION AUTHORIZATION regressuser2; +SELECT session_user, current_user; + session_user | current_user +--------------+-------------- + regressuser2 | regressuser2 +(1 row) + +-- try various combinations of queries on atest1 and atest2 +SELECT * FROM atest1; -- ok + a | b +---+--- +(0 rows) + +SELECT * FROM atest2; -- ok + col1 | col2 +------+------ +(0 rows) + +INSERT INTO atest1 VALUES (2, 'two'); -- ok +INSERT INTO atest2 VALUES ('foo', true); -- fail +ERROR: permission denied for relation atest2 +INSERT INTO atest1 SELECT 1, b FROM atest1; -- ok +UPDATE atest1 SET a = 1 WHERE a = 2; -- ok +ERROR: Partition column can't be updated in current version +UPDATE atest2 SET col2 = NOT col2; -- fail +ERROR: permission denied for relation atest2 +SELECT * FROM atest1 FOR UPDATE; -- ok + a | b +---+----- + 2 | two +(1 row) + +SELECT * FROM atest2 FOR UPDATE; -- fail +ERROR: permission denied for relation atest2 +DELETE FROM atest2; -- fail +ERROR: permission denied for relation atest2 +TRUNCATE atest2; -- fail +ERROR: permission denied for relation atest2 +BEGIN; +LOCK atest2 IN ACCESS EXCLUSIVE MODE; -- fail +ERROR: permission denied for relation atest2 +COMMIT; +COPY atest2 FROM stdin; -- fail +ERROR: permission denied for relation atest2 +GRANT ALL ON atest1 TO PUBLIC; -- fail +WARNING: no privileges were granted for "atest1" +-- checks in subquery, both ok +SELECT * FROM atest1 WHERE ( b IN ( SELECT col1 FROM atest2 ) ); + a | b +---+--- +(0 rows) + +SELECT * FROM atest2 WHERE ( col1 IN ( SELECT b FROM atest1 ) ); + col1 | col2 +------+------ +(0 rows) + +SET SESSION AUTHORIZATION regressuser3; +SELECT session_user, current_user; + session_user | current_user +--------------+-------------- + regressuser3 | regressuser3 +(1 row) + +SELECT * FROM atest1; -- ok + a | b +---+----- + 2 | two +(1 row) + +SELECT * FROM atest2; -- fail +ERROR: permission denied for relation atest2 +INSERT INTO atest1 VALUES (2, 'two'); -- fail +ERROR: permission denied for relation atest1 +INSERT INTO atest2 VALUES ('foo', true); -- fail +ERROR: permission denied for relation atest2 +INSERT INTO atest1 SELECT 1, b FROM atest1; -- fail +ERROR: permission denied for relation atest1 +UPDATE atest1 SET a = 1 WHERE a = 2; -- fail +ERROR: Partition column can't be updated in current version +UPDATE atest2 SET col2 = NULL; -- ok +UPDATE atest2 SET col2 = NOT col2; -- fails; requires SELECT on atest2 +ERROR: permission denied for relation atest2 +UPDATE atest2 SET col2 = true FROM atest1 WHERE atest1.a = 5; -- ok +SELECT * FROM atest1 FOR UPDATE; -- fail +ERROR: permission denied for relation atest1 +SELECT * FROM atest2 FOR UPDATE; -- fail +ERROR: permission denied for relation atest2 +DELETE FROM atest2; -- fail +ERROR: permission denied for relation atest2 +TRUNCATE atest2; -- fail +ERROR: permission denied for relation atest2 +BEGIN; +LOCK atest2 IN ACCESS EXCLUSIVE MODE; -- ok +COMMIT; +COPY atest2 FROM stdin; -- fail +ERROR: permission denied for relation atest2 +-- checks in subquery, both fail +SELECT * FROM atest1 WHERE ( b IN ( SELECT col1 FROM atest2 ) ); +ERROR: permission denied for relation atest2 +SELECT * FROM atest2 WHERE ( col1 IN ( SELECT b FROM atest1 ) ); +ERROR: permission denied for relation atest2 +SET SESSION AUTHORIZATION regressuser4; +COPY atest2 FROM stdin; -- ok +SELECT * FROM atest1; -- ok + a | b +---+----- + 2 | two +(1 row) + +-- groups +SET SESSION AUTHORIZATION regressuser3; +CREATE TABLE atest3 (one int, two int, three int); +GRANT DELETE ON atest3 TO GROUP regressgroup2; +SET SESSION AUTHORIZATION regressuser1; +SELECT * FROM atest3; -- fail +ERROR: permission denied for relation atest3 +DELETE FROM atest3; -- ok +-- views +SET SESSION AUTHORIZATION regressuser3; +CREATE VIEW atestv1 AS SELECT * FROM atest1; -- ok +/* The next *should* fail, but it's not implemented that way yet. */ +CREATE VIEW atestv2 AS SELECT * FROM atest2; +CREATE VIEW atestv3 AS SELECT * FROM atest3; -- ok +SELECT * FROM atestv1; -- ok + a | b +---+----- + 2 | two +(1 row) + +SELECT * FROM atestv2; -- fail +ERROR: permission denied for relation atest2 +GRANT SELECT ON atestv1, atestv3 TO regressuser4; +GRANT SELECT ON atestv2 TO regressuser2; +SET SESSION AUTHORIZATION regressuser4; +SELECT * FROM atestv1; -- ok + a | b +---+----- + 2 | two +(1 row) + +SELECT * FROM atestv2; -- fail +ERROR: permission denied for relation atestv2 +SELECT * FROM atestv3; -- ok + one | two | three +-----+-----+------- +(0 rows) + +CREATE VIEW atestv4 AS SELECT * FROM atestv3; -- nested view +SELECT * FROM atestv4; -- ok + one | two | three +-----+-----+------- +(0 rows) + +GRANT SELECT ON atestv4 TO regressuser2; +SET SESSION AUTHORIZATION regressuser2; +-- Two complex cases: +SELECT * FROM atestv3; -- fail +ERROR: permission denied for relation atestv3 +SELECT * FROM atestv4; -- ok (even though regressuser2 cannot access underlying atestv3) + one | two | three +-----+-----+------- +(0 rows) + +SELECT * FROM atest2; -- ok + col1 | col2 +------+------ + bar | t +(1 row) + +SELECT * FROM atestv2; -- fail (even though regressuser2 can access underlying atest2) +ERROR: permission denied for relation atest2 +-- Test column level permissions +SET SESSION AUTHORIZATION regressuser1; +CREATE TABLE atest5 (one int, two int, three int); +CREATE TABLE atest6 (one int, two int, blue int); +GRANT SELECT (one), INSERT (two), UPDATE (three) ON atest5 TO regressuser4; +GRANT ALL (one) ON atest5 TO regressuser3; +INSERT INTO atest5 VALUES (1,2,3); +SET SESSION AUTHORIZATION regressuser4; +SELECT * FROM atest5; -- fail +ERROR: permission denied for relation atest5 +SELECT one FROM atest5; -- ok + one +----- + 1 +(1 row) + +COPY atest5 (one) TO stdout; -- ok +1 +SELECT two FROM atest5; -- fail +ERROR: permission denied for relation atest5 +COPY atest5 (two) TO stdout; -- fail +ERROR: permission denied for relation atest5 +SELECT atest5 FROM atest5; -- fail +ERROR: permission denied for relation atest5 +COPY atest5 (one,two) TO stdout; -- fail +ERROR: permission denied for relation atest5 +SELECT 1 FROM atest5; -- ok + ?column? +---------- + 1 +(1 row) + +SELECT 1 FROM atest5 a JOIN atest5 b USING (one); -- ok + ?column? +---------- + 1 +(1 row) + +SELECT 1 FROM atest5 a JOIN atest5 b USING (two); -- fail +ERROR: permission denied for relation atest5 +SELECT 1 FROM atest5 a NATURAL JOIN atest5 b; -- fail +ERROR: permission denied for relation atest5 +SELECT (j.*) IS NULL FROM (atest5 a JOIN atest5 b USING (one)) j; -- fail +ERROR: permission denied for relation atest5 +SELECT 1 FROM atest5 WHERE two = 2; -- fail +ERROR: permission denied for relation atest5 +SELECT * FROM atest1, atest5; -- fail +ERROR: permission denied for relation atest5 +SELECT atest1.* FROM atest1, atest5; -- ok + a | b +---+----- + 2 | two +(1 row) + +SELECT atest1.*,atest5.one FROM atest1, atest5; -- ok + a | b | one +---+-----+----- + 2 | two | 1 +(1 row) + +SELECT atest1.*,atest5.one FROM atest1 JOIN atest5 ON (atest1.a = atest5.two); -- fail +ERROR: permission denied for relation atest5 +SELECT atest1.*,atest5.one FROM atest1 JOIN atest5 ON (atest1.a = atest5.one); -- ok + a | b | one +---+---+----- +(0 rows) + +SELECT one, two FROM atest5; -- fail +ERROR: permission denied for relation atest5 +SET SESSION AUTHORIZATION regressuser1; +GRANT SELECT (one,two) ON atest6 TO regressuser4; +SET SESSION AUTHORIZATION regressuser4; +SELECT one, two FROM atest5 NATURAL JOIN atest6; -- fail still +ERROR: permission denied for relation atest5 +SET SESSION AUTHORIZATION regressuser1; +GRANT SELECT (two) ON atest5 TO regressuser4; +SET SESSION AUTHORIZATION regressuser4; +SELECT one, two FROM atest5 NATURAL JOIN atest6; -- ok now + one | two +-----+----- +(0 rows) + +-- test column-level privileges for INSERT and UPDATE +INSERT INTO atest5 (two) VALUES (3); -- ok +COPY atest5 FROM stdin; -- fail +ERROR: permission denied for relation atest5 +COPY atest5 (two) FROM stdin; -- ok +INSERT INTO atest5 (three) VALUES (4); -- fail +ERROR: permission denied for relation atest5 +INSERT INTO atest5 VALUES (5,5,5); -- fail +ERROR: permission denied for relation atest5 +UPDATE atest5 SET three = 10; -- ok +UPDATE atest5 SET one = 8; -- fail +ERROR: Partition column can't be updated in current version +UPDATE atest5 SET three = 5, one = 2; -- fail +ERROR: Partition column can't be updated in current version +SET SESSION AUTHORIZATION regressuser1; +REVOKE ALL (one) ON atest5 FROM regressuser4; +GRANT SELECT (one,two,blue) ON atest6 TO regressuser4; +SET SESSION AUTHORIZATION regressuser4; +SELECT one FROM atest5; -- fail +ERROR: permission denied for relation atest5 +UPDATE atest5 SET one = 1; -- fail +ERROR: Partition column can't be updated in current version +SELECT atest6 FROM atest6; -- ok + atest6 +-------- +(0 rows) + +COPY atest6 TO stdout; -- ok +-- test column-level privileges when involved with DELETE +SET SESSION AUTHORIZATION regressuser1; +ALTER TABLE atest6 ADD COLUMN three integer; +GRANT DELETE ON atest5 TO regressuser3; +GRANT SELECT (two) ON atest5 TO regressuser3; +REVOKE ALL (one) ON atest5 FROM regressuser3; +GRANT SELECT (one) ON atest5 TO regressuser4; +SET SESSION AUTHORIZATION regressuser4; +SELECT atest6 FROM atest6; -- fail +ERROR: permission denied for relation atest6 +SELECT one FROM atest5 NATURAL JOIN atest6; -- fail +ERROR: permission denied for relation atest5 +SET SESSION AUTHORIZATION regressuser1; +ALTER TABLE atest6 DROP COLUMN three; +SET SESSION AUTHORIZATION regressuser4; +SELECT atest6 FROM atest6; -- ok + atest6 +-------- +(0 rows) + +SELECT one FROM atest5 NATURAL JOIN atest6; -- ok + one +----- +(0 rows) + +SET SESSION AUTHORIZATION regressuser1; +ALTER TABLE atest6 DROP COLUMN two; +REVOKE SELECT (one,blue) ON atest6 FROM regressuser4; +SET SESSION AUTHORIZATION regressuser4; +SELECT * FROM atest6; -- fail +ERROR: permission denied for relation atest6 +SELECT 1 FROM atest6; -- fail +ERROR: permission denied for relation atest6 +SET SESSION AUTHORIZATION regressuser3; +DELETE FROM atest5 WHERE one = 1; -- fail +ERROR: permission denied for relation atest5 +DELETE FROM atest5 WHERE two = 2; -- ok +-- check inheritance cases +SET SESSION AUTHORIZATION regressuser1; +CREATE TABLE atestp1 (f1 int, f2 int) WITH OIDS; +CREATE TABLE atestp2 (fx int, fy int) WITH OIDS; +CREATE TABLE atestc (fz int) INHERITS (atestp1, atestp2); +ERROR: Cannot currently distribute a table with more than one parent. +GRANT SELECT(fx,fy,oid) ON atestp2 TO regressuser2; +GRANT SELECT(fx) ON atestc TO regressuser2; +ERROR: relation "atestc" does not exist +SET SESSION AUTHORIZATION regressuser2; +SELECT fx FROM atestp2; -- ok + fx +---- +(0 rows) + +SELECT fy FROM atestp2; -- ok + fy +---- +(0 rows) + +SELECT atestp2 FROM atestp2; -- ok + atestp2 +--------- +(0 rows) + +SELECT oid FROM atestp2; -- ok + oid +----- +(0 rows) + +SELECT fy FROM atestc; -- fail +ERROR: relation "atestc" does not exist +LINE 1: SELECT fy FROM atestc; + ^ +SET SESSION AUTHORIZATION regressuser1; +GRANT SELECT(fy,oid) ON atestc TO regressuser2; +ERROR: relation "atestc" does not exist +SET SESSION AUTHORIZATION regressuser2; +SELECT fx FROM atestp2; -- still ok + fx +---- +(0 rows) + +SELECT fy FROM atestp2; -- ok + fy +---- +(0 rows) + +SELECT atestp2 FROM atestp2; -- ok + atestp2 +--------- +(0 rows) + +SELECT oid FROM atestp2; -- ok + oid +----- +(0 rows) + +-- privileges on functions, languages +-- switch to superuser +\c - +REVOKE ALL PRIVILEGES ON LANGUAGE sql FROM PUBLIC; +GRANT USAGE ON LANGUAGE sql TO regressuser1; -- ok +GRANT USAGE ON LANGUAGE c TO PUBLIC; -- fail +ERROR: language "c" is not trusted +HINT: Only superusers can use untrusted languages. +SET SESSION AUTHORIZATION regressuser1; +GRANT USAGE ON LANGUAGE sql TO regressuser2; -- fail +WARNING: no privileges were granted for "sql" +CREATE FUNCTION testfunc1(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sql; +ERROR: stable and volatile not yet supported, function volatility has to be immutable +CREATE FUNCTION testfunc2(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sql; +ERROR: stable and volatile not yet supported, function volatility has to be immutable +REVOKE ALL ON FUNCTION testfunc1(int), testfunc2(int) FROM PUBLIC; +ERROR: function testfunc1(integer) does not exist +GRANT EXECUTE ON FUNCTION testfunc1(int), testfunc2(int) TO regressuser2; +ERROR: function testfunc1(integer) does not exist +GRANT USAGE ON FUNCTION testfunc1(int) TO regressuser3; -- semantic error +ERROR: function testfunc1(integer) does not exist +GRANT ALL PRIVILEGES ON FUNCTION testfunc1(int) TO regressuser4; +ERROR: function testfunc1(integer) does not exist +GRANT ALL PRIVILEGES ON FUNCTION testfunc_nosuch(int) TO regressuser4; +ERROR: function testfunc_nosuch(integer) does not exist +CREATE FUNCTION testfunc4(boolean) RETURNS text + AS 'select col1 from atest2 where col2 = $1;' + LANGUAGE sql SECURITY DEFINER; +ERROR: stable and volatile not yet supported, function volatility has to be immutable +GRANT EXECUTE ON FUNCTION testfunc4(boolean) TO regressuser3; +ERROR: function testfunc4(boolean) does not exist +SET SESSION AUTHORIZATION regressuser2; +SELECT testfunc1(5), testfunc2(5); -- ok +ERROR: function testfunc1(integer) does not exist +LINE 1: SELECT testfunc1(5), testfunc2(5); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CREATE FUNCTION testfunc3(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sql; -- fail +ERROR: permission denied for language sql +SET SESSION AUTHORIZATION regressuser3; +SELECT testfunc1(5); -- fail +ERROR: function testfunc1(integer) does not exist +LINE 1: SELECT testfunc1(5); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +SELECT col1 FROM atest2 WHERE col2 = true; -- fail +ERROR: permission denied for relation atest2 +SELECT testfunc4(true); -- ok +ERROR: function testfunc4(boolean) does not exist +LINE 1: SELECT testfunc4(true); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +SET SESSION AUTHORIZATION regressuser4; +SELECT testfunc1(5); -- ok +ERROR: function testfunc1(integer) does not exist +LINE 1: SELECT testfunc1(5); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +DROP FUNCTION testfunc1(int); -- fail +ERROR: function testfunc1(integer) does not exist +\c - +DROP FUNCTION testfunc1(int); -- ok +ERROR: function testfunc1(integer) does not exist +-- restore to sanity +GRANT ALL PRIVILEGES ON LANGUAGE sql TO PUBLIC; +-- truncate +SET SESSION AUTHORIZATION regressuser5; +TRUNCATE atest2; -- ok +TRUNCATE atest3; -- fail +ERROR: permission denied for relation atest3 +-- has_table_privilege function +-- bad-input checks +select has_table_privilege(NULL,'pg_authid','select'); + has_table_privilege +--------------------- + +(1 row) + +select has_table_privilege('pg_shad','select'); +ERROR: relation "pg_shad" does not exist +select has_table_privilege('nosuchuser','pg_authid','select'); +ERROR: role "nosuchuser" does not exist +select has_table_privilege('pg_authid','sel'); +ERROR: unrecognized privilege type: "sel" +select has_table_privilege(-999999,'pg_authid','update'); +ERROR: role with OID 4293967297 does not exist +select has_table_privilege(1,'select'); + has_table_privilege +--------------------- + +(1 row) + +-- superuser +\c - +select has_table_privilege(current_user,'pg_authid','select'); + has_table_privilege +--------------------- + t +(1 row) + +select has_table_privilege(current_user,'pg_authid','insert'); + has_table_privilege +--------------------- + t +(1 row) + +select has_table_privilege(t2.oid,'pg_authid','update') +from (select oid from pg_roles where rolname = current_user) as t2; + has_table_privilege +--------------------- + t +(1 row) + +select has_table_privilege(t2.oid,'pg_authid','delete') +from (select oid from pg_roles where rolname = current_user) as t2; + has_table_privilege +--------------------- + t +(1 row) + +-- 'rule' privilege no longer exists, but for backwards compatibility +-- has_table_privilege still recognizes the keyword and says FALSE +select has_table_privilege(current_user,t1.oid,'rule') +from (select oid from pg_class where relname = 'pg_authid') as t1; + has_table_privilege +--------------------- + f +(1 row) + +select has_table_privilege(current_user,t1.oid,'references') +from (select oid from pg_class where relname = 'pg_authid') as t1; + has_table_privilege +--------------------- + t +(1 row) + +select has_table_privilege(t2.oid,t1.oid,'select') +from (select oid from pg_class where relname = 'pg_authid') as t1, + (select oid from pg_roles where rolname = current_user) as t2; + has_table_privilege +--------------------- + t +(1 row) + +select has_table_privilege(t2.oid,t1.oid,'insert') +from (select oid from pg_class where relname = 'pg_authid') as t1, + (select oid from pg_roles where rolname = current_user) as t2; + has_table_privilege +--------------------- + t +(1 row) + +select has_table_privilege('pg_authid','update'); + has_table_privilege +--------------------- + t +(1 row) + +select has_table_privilege('pg_authid','delete'); + has_table_privilege +--------------------- + t +(1 row) + +select has_table_privilege('pg_authid','truncate'); + has_table_privilege +--------------------- + t +(1 row) + +select has_table_privilege(t1.oid,'select') +from (select oid from pg_class where relname = 'pg_authid') as t1; + has_table_privilege +--------------------- + t +(1 row) + +select has_table_privilege(t1.oid,'trigger') +from (select oid from pg_class where relname = 'pg_authid') as t1; + has_table_privilege +--------------------- + t +(1 row) + +-- non-superuser +SET SESSION AUTHORIZATION regressuser3; +select has_table_privilege(current_user,'pg_class','select'); + has_table_privilege +--------------------- + t +(1 row) + +select has_table_privilege(current_user,'pg_class','insert'); + has_table_privilege +--------------------- + f +(1 row) + +select has_table_privilege(t2.oid,'pg_class','update') +from (select oid from pg_roles where rolname = current_user) as t2; + has_table_privilege +--------------------- + f +(1 row) + +select has_table_privilege(t2.oid,'pg_class','delete') +from (select oid from pg_roles where rolname = current_user) as t2; + has_table_privilege +--------------------- + f +(1 row) + +select has_table_privilege(current_user,t1.oid,'references') +from (select oid from pg_class where relname = 'pg_class') as t1; + has_table_privilege +--------------------- + f +(1 row) + +select has_table_privilege(t2.oid,t1.oid,'select') +from (select oid from pg_class where relname = 'pg_class') as t1, + (select oid from pg_roles where rolname = current_user) as t2; + has_table_privilege +--------------------- + t +(1 row) + +select has_table_privilege(t2.oid,t1.oid,'insert') +from (select oid from pg_class where relname = 'pg_class') as t1, + (select oid from pg_roles where rolname = current_user) as t2; + has_table_privilege +--------------------- + f +(1 row) + +select has_table_privilege('pg_class','update'); + has_table_privilege +--------------------- + f +(1 row) + +select has_table_privilege('pg_class','delete'); + has_table_privilege +--------------------- + f +(1 row) + +select has_table_privilege('pg_class','truncate'); + has_table_privilege +--------------------- + f +(1 row) + +select has_table_privilege(t1.oid,'select') +from (select oid from pg_class where relname = 'pg_class') as t1; + has_table_privilege +--------------------- + t +(1 row) + +select has_table_privilege(t1.oid,'trigger') +from (select oid from pg_class where relname = 'pg_class') as t1; + has_table_privilege +--------------------- + f +(1 row) + +select has_table_privilege(current_user,'atest1','select'); + has_table_privilege +--------------------- + t +(1 row) + +select has_table_privilege(current_user,'atest1','insert'); + has_table_privilege +--------------------- + f +(1 row) + +select has_table_privilege(t2.oid,'atest1','update') +from (select oid from pg_roles where rolname = current_user) as t2; + has_table_privilege +--------------------- + f +(1 row) + +select has_table_privilege(t2.oid,'atest1','delete') +from (select oid from pg_roles where rolname = current_user) as t2; + has_table_privilege +--------------------- + f +(1 row) + +select has_table_privilege(current_user,t1.oid,'references') +from (select oid from pg_class where relname = 'atest1') as t1; + has_table_privilege +--------------------- + f +(1 row) + +select has_table_privilege(t2.oid,t1.oid,'select') +from (select oid from pg_class where relname = 'atest1') as t1, + (select oid from pg_roles where rolname = current_user) as t2; + has_table_privilege +--------------------- + t +(1 row) + +select has_table_privilege(t2.oid,t1.oid,'insert') +from (select oid from pg_class where relname = 'atest1') as t1, + (select oid from pg_roles where rolname = current_user) as t2; + has_table_privilege +--------------------- + f +(1 row) + +select has_table_privilege('atest1','update'); + has_table_privilege +--------------------- + f +(1 row) + +select has_table_privilege('atest1','delete'); + has_table_privilege +--------------------- + f +(1 row) + +select has_table_privilege('atest1','truncate'); + has_table_privilege +--------------------- + f +(1 row) + +select has_table_privilege(t1.oid,'select') +from (select oid from pg_class where relname = 'atest1') as t1; + has_table_privilege +--------------------- + t +(1 row) + +select has_table_privilege(t1.oid,'trigger') +from (select oid from pg_class where relname = 'atest1') as t1; + has_table_privilege +--------------------- + f +(1 row) + +-- Grant options +SET SESSION AUTHORIZATION regressuser1; +CREATE TABLE atest4 (a int); +GRANT SELECT ON atest4 TO regressuser2 WITH GRANT OPTION; +GRANT UPDATE ON atest4 TO regressuser2; +GRANT SELECT ON atest4 TO GROUP regressgroup1 WITH GRANT OPTION; +SET SESSION AUTHORIZATION regressuser2; +GRANT SELECT ON atest4 TO regressuser3; +GRANT UPDATE ON atest4 TO regressuser3; -- fail +WARNING: no privileges were granted for "atest4" +SET SESSION AUTHORIZATION regressuser1; +REVOKE SELECT ON atest4 FROM regressuser3; -- does nothing +SELECT has_table_privilege('regressuser3', 'atest4', 'SELECT'); -- true + has_table_privilege +--------------------- + t +(1 row) + +REVOKE SELECT ON atest4 FROM regressuser2; -- fail +ERROR: dependent privileges exist +HINT: Use CASCADE to revoke them too. +REVOKE GRANT OPTION FOR SELECT ON atest4 FROM regressuser2 CASCADE; -- ok +SELECT has_table_privilege('regressuser2', 'atest4', 'SELECT'); -- true + has_table_privilege +--------------------- + t +(1 row) + +SELECT has_table_privilege('regressuser3', 'atest4', 'SELECT'); -- false + has_table_privilege +--------------------- + f +(1 row) + +SELECT has_table_privilege('regressuser1', 'atest4', 'SELECT WITH GRANT OPTION'); -- true + has_table_privilege +--------------------- + t +(1 row) + +-- has_sequence_privilege tests +\c - +CREATE SEQUENCE x_seq; +GRANT USAGE on x_seq to regressuser2; +SELECT has_sequence_privilege('regressuser1', 'atest1', 'SELECT'); +ERROR: "atest1" is not a sequence +SELECT has_sequence_privilege('regressuser1', 'x_seq', 'INSERT'); +ERROR: unrecognized privilege type: "INSERT" +SELECT has_sequence_privilege('regressuser1', 'x_seq', 'SELECT'); + has_sequence_privilege +------------------------ + f +(1 row) + +SET SESSION AUTHORIZATION regressuser2; +SELECT has_sequence_privilege('x_seq', 'USAGE'); + has_sequence_privilege +------------------------ + t +(1 row) + +-- largeobject privilege tests +\c - +SET SESSION AUTHORIZATION regressuser1; +SELECT lo_create(1001); + lo_create +----------- + 1001 +(1 row) + +SELECT lo_create(1002); + lo_create +----------- + 1002 +(1 row) + +SELECT lo_create(1003); + lo_create +----------- + 1003 +(1 row) + +SELECT lo_create(1004); + lo_create +----------- + 1004 +(1 row) + +SELECT lo_create(1005); + lo_create +----------- + 1005 +(1 row) + +GRANT ALL ON LARGE OBJECT 1001 TO PUBLIC; +GRANT SELECT ON LARGE OBJECT 1003 TO regressuser2; +GRANT SELECT,UPDATE ON LARGE OBJECT 1004 TO regressuser2; +GRANT ALL ON LARGE OBJECT 1005 TO regressuser2; +GRANT SELECT ON LARGE OBJECT 1005 TO regressuser2 WITH GRANT OPTION; +GRANT SELECT, INSERT ON LARGE OBJECT 1001 TO PUBLIC; -- to be failed +ERROR: invalid privilege type INSERT for large object +GRANT SELECT, UPDATE ON LARGE OBJECT 1001 TO nosuchuser; -- to be failed +ERROR: role "nosuchuser" does not exist +GRANT SELECT, UPDATE ON LARGE OBJECT 999 TO PUBLIC; -- to be failed +ERROR: large object 999 does not exist +\c - +SET SESSION AUTHORIZATION regressuser2; +SELECT lo_create(2001); + lo_create +----------- + 2001 +(1 row) + +SELECT lo_create(2002); + lo_create +----------- + 2002 +(1 row) + +SELECT loread(lo_open(1001, x'40000'::int), 32); + loread +-------- + \x +(1 row) + +SELECT loread(lo_open(1002, x'40000'::int), 32); -- to be denied +ERROR: permission denied for large object 1002 +SELECT loread(lo_open(1003, x'40000'::int), 32); + loread +-------- + \x +(1 row) + +SELECT loread(lo_open(1004, x'40000'::int), 32); + loread +-------- + \x +(1 row) + +SELECT lowrite(lo_open(1001, x'20000'::int), 'abcd'); + lowrite +--------- + 4 +(1 row) + +SELECT lowrite(lo_open(1002, x'20000'::int), 'abcd'); -- to be denied +ERROR: permission denied for large object 1002 +SELECT lowrite(lo_open(1003, x'20000'::int), 'abcd'); -- to be denied +ERROR: permission denied for large object 1003 +SELECT lowrite(lo_open(1004, x'20000'::int), 'abcd'); + lowrite +--------- + 4 +(1 row) + +GRANT SELECT ON LARGE OBJECT 1005 TO regressuser3; +GRANT UPDATE ON LARGE OBJECT 1006 TO regressuser3; -- to be denied +ERROR: large object 1006 does not exist +REVOKE ALL ON LARGE OBJECT 2001, 2002 FROM PUBLIC; +GRANT ALL ON LARGE OBJECT 2001 TO regressuser3; +SELECT lo_unlink(1001); -- to be denied +ERROR: must be owner of large object 1001 +SELECT lo_unlink(2002); + lo_unlink +----------- + 1 +(1 row) + +\c - +-- confirm ACL setting +SELECT oid, pg_get_userbyid(lomowner) ownername, lomacl FROM pg_largeobject_metadata; + oid | ownername | lomacl +------+--------------+------------------------------------------------------------------------------------------ + 1002 | regressuser1 | + 1001 | regressuser1 | {regressuser1=rw/regressuser1,=rw/regressuser1} + 1003 | regressuser1 | {regressuser1=rw/regressuser1,regressuser2=r/regressuser1} + 1004 | regressuser1 | {regressuser1=rw/regressuser1,regressuser2=rw/regressuser1} + 1005 | regressuser1 | {regressuser1=rw/regressuser1,regressuser2=r*w/regressuser1,regressuser3=r/regressuser2} + 2001 | regressuser2 | {regressuser2=rw/regressuser2,regressuser3=rw/regressuser2} +(6 rows) + +SET SESSION AUTHORIZATION regressuser3; +SELECT loread(lo_open(1001, x'40000'::int), 32); + loread +------------ + \x61626364 +(1 row) + +SELECT loread(lo_open(1003, x'40000'::int), 32); -- to be denied +ERROR: permission denied for large object 1003 +SELECT loread(lo_open(1005, x'40000'::int), 32); + loread +-------- + \x +(1 row) + +SELECT lo_truncate(lo_open(1005, x'20000'::int), 10); -- to be denied +ERROR: permission denied for large object 1005 +SELECT lo_truncate(lo_open(2001, x'20000'::int), 10); + lo_truncate +------------- + 0 +(1 row) + +-- compatibility mode in largeobject permission +\c - +SET lo_compat_privileges = false; -- default setting +SET SESSION AUTHORIZATION regressuser4; +SELECT loread(lo_open(1002, x'40000'::int), 32); -- to be denied +ERROR: permission denied for large object 1002 +SELECT lowrite(lo_open(1002, x'20000'::int), 'abcd'); -- to be denied +ERROR: permission denied for large object 1002 +SELECT lo_truncate(lo_open(1002, x'20000'::int), 10); -- to be denied +ERROR: permission denied for large object 1002 +SELECT lo_unlink(1002); -- to be denied +ERROR: must be owner of large object 1002 +SELECT lo_export(1001, '/dev/null'); -- to be denied +ERROR: must be superuser to use server-side lo_export() +HINT: Anyone can use the client-side lo_export() provided by libpq. +\c - +SET lo_compat_privileges = true; -- compatibility mode +SET SESSION AUTHORIZATION regressuser4; +SELECT loread(lo_open(1002, x'40000'::int), 32); + loread +-------- + \x +(1 row) + +SELECT lowrite(lo_open(1002, x'20000'::int), 'abcd'); + lowrite +--------- + 4 +(1 row) + +SELECT lo_truncate(lo_open(1002, x'20000'::int), 10); + lo_truncate +------------- + 0 +(1 row) + +SELECT lo_unlink(1002); + lo_unlink +----------- + 1 +(1 row) + +SELECT lo_export(1001, '/dev/null'); -- to be denied +ERROR: must be superuser to use server-side lo_export() +HINT: Anyone can use the client-side lo_export() provided by libpq. +-- don't allow unpriv users to access pg_largeobject contents +\c - +SELECT * FROM pg_largeobject LIMIT 0; + loid | pageno | data +------+--------+------ +(0 rows) + +SET SESSION AUTHORIZATION regressuser1; +SELECT * FROM pg_largeobject LIMIT 0; -- to be denied +ERROR: permission denied for relation pg_largeobject +-- test default ACLs +\c - +CREATE SCHEMA testns; +GRANT ALL ON SCHEMA testns TO regressuser1; +CREATE TABLE testns.acltest1 (x int); +SELECT has_table_privilege('regressuser1', 'testns.acltest1', 'SELECT'); -- no + has_table_privilege +--------------------- + f +(1 row) + +SELECT has_table_privilege('regressuser1', 'testns.acltest1', 'INSERT'); -- no + has_table_privilege +--------------------- + f +(1 row) + +ALTER DEFAULT PRIVILEGES IN SCHEMA testns GRANT SELECT ON TABLES TO public; +SELECT has_table_privilege('regressuser1', 'testns.acltest1', 'SELECT'); -- no + has_table_privilege +--------------------- + f +(1 row) + +SELECT has_table_privilege('regressuser1', 'testns.acltest1', 'INSERT'); -- no + has_table_privilege +--------------------- + f +(1 row) + +DROP TABLE testns.acltest1; +CREATE TABLE testns.acltest1 (x int); +SELECT has_table_privilege('regressuser1', 'testns.acltest1', 'SELECT'); -- yes + has_table_privilege +--------------------- + t +(1 row) + +SELECT has_table_privilege('regressuser1', 'testns.acltest1', 'INSERT'); -- no + has_table_privilege +--------------------- + f +(1 row) + +ALTER DEFAULT PRIVILEGES IN SCHEMA testns GRANT INSERT ON TABLES TO regressuser1; +DROP TABLE testns.acltest1; +CREATE TABLE testns.acltest1 (x int); +SELECT has_table_privilege('regressuser1', 'testns.acltest1', 'SELECT'); -- yes + has_table_privilege +--------------------- + t +(1 row) + +SELECT has_table_privilege('regressuser1', 'testns.acltest1', 'INSERT'); -- yes + has_table_privilege +--------------------- + t +(1 row) + +ALTER DEFAULT PRIVILEGES IN SCHEMA testns REVOKE INSERT ON TABLES FROM regressuser1; +DROP TABLE testns.acltest1; +CREATE TABLE testns.acltest1 (x int); +SELECT has_table_privilege('regressuser1', 'testns.acltest1', 'SELECT'); -- yes + has_table_privilege +--------------------- + t +(1 row) + +SELECT has_table_privilege('regressuser1', 'testns.acltest1', 'INSERT'); -- no + has_table_privilege +--------------------- + f +(1 row) + +ALTER DEFAULT PRIVILEGES FOR ROLE regressuser1 REVOKE EXECUTE ON FUNCTIONS FROM public; +SET ROLE regressuser1; +CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sql; +ERROR: stable and volatile not yet supported, function volatility has to be immutable +SELECT has_function_privilege('regressuser2', 'testns.foo()', 'EXECUTE'); -- no +ERROR: function "testns.foo()" does not exist +ALTER DEFAULT PRIVILEGES IN SCHEMA testns GRANT EXECUTE ON FUNCTIONS to public; +DROP FUNCTION testns.foo(); +ERROR: function testns.foo() does not exist +CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sql; +ERROR: stable and volatile not yet supported, function volatility has to be immutable +SELECT has_function_privilege('regressuser2', 'testns.foo()', 'EXECUTE'); -- yes +ERROR: function "testns.foo()" does not exist +DROP FUNCTION testns.foo(); +ERROR: function testns.foo() does not exist +RESET ROLE; +SELECT count(*) + FROM pg_default_acl d LEFT JOIN pg_namespace n ON defaclnamespace = n.oid + WHERE nspname = 'testns'; + count +------- + 2 +(1 row) + +DROP SCHEMA testns CASCADE; +NOTICE: drop cascades to table testns.acltest1 +SELECT d.* -- check that entries went away + FROM pg_default_acl d LEFT JOIN pg_namespace n ON defaclnamespace = n.oid + WHERE nspname IS NULL AND defaclnamespace != 0; + defaclrole | defaclnamespace | defaclobjtype | defaclacl +------------+-----------------+---------------+----------- +(0 rows) + +-- Grant on all objects of given type in a schema +\c - +CREATE SCHEMA testns; +CREATE TABLE testns.t1 (f1 int); +CREATE TABLE testns.t2 (f1 int); +SELECT has_table_privilege('regressuser1', 'testns.t1', 'SELECT'); -- false + has_table_privilege +--------------------- + f +(1 row) + +GRANT ALL ON ALL TABLES IN SCHEMA testns TO regressuser1; +SELECT has_table_privilege('regressuser1', 'testns.t1', 'SELECT'); -- true + has_table_privilege +--------------------- + t +(1 row) + +SELECT has_table_privilege('regressuser1', 'testns.t2', 'SELECT'); -- true + has_table_privilege +--------------------- + t +(1 row) + +REVOKE ALL ON ALL TABLES IN SCHEMA testns FROM regressuser1; +SELECT has_table_privilege('regressuser1', 'testns.t1', 'SELECT'); -- false + has_table_privilege +--------------------- + f +(1 row) + +SELECT has_table_privilege('regressuser1', 'testns.t2', 'SELECT'); -- false + has_table_privilege +--------------------- + f +(1 row) + +CREATE FUNCTION testns.testfunc(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sql; +SELECT has_function_privilege('regressuser1', 'testns.testfunc(int)', 'EXECUTE'); -- true by default + has_function_privilege +------------------------ + t +(1 row) + +REVOKE ALL ON ALL FUNCTIONS IN SCHEMA testns FROM PUBLIC; +SELECT has_function_privilege('regressuser1', 'testns.testfunc(int)', 'EXECUTE'); -- false + has_function_privilege +------------------------ + f +(1 row) + +SET client_min_messages TO 'warning'; +DROP SCHEMA testns CASCADE; +RESET client_min_messages; +-- clean up +\c +drop sequence x_seq; +DROP FUNCTION testfunc2(int); +ERROR: function testfunc2(integer) does not exist +DROP FUNCTION testfunc4(boolean); +ERROR: function testfunc4(boolean) does not exist +DROP VIEW atestv1; +ERROR: view "atestv1" does not exist +DROP VIEW atestv2; +ERROR: view "atestv2" does not exist +-- this should cascade to drop atestv4 +DROP VIEW atestv3 CASCADE; +NOTICE: drop cascades to view atestv4 +ERROR: view "atestv3" does not exist +-- this should complain "does not exist" +DROP VIEW atestv4; +ERROR: view "atestv4" does not exist +DROP TABLE atest1; +ERROR: cannot drop table atest1 because other objects depend on it +DETAIL: view atestv1 depends on table atest1 +HINT: Use DROP ... CASCADE to drop the dependent objects too. +DROP TABLE atest2; +ERROR: cannot drop table atest2 because other objects depend on it +DETAIL: view atestv2 depends on table atest2 +HINT: Use DROP ... CASCADE to drop the dependent objects too. +DROP TABLE atest3; +ERROR: cannot drop table atest3 because other objects depend on it +DETAIL: view atestv3 depends on table atest3 +view atestv4 depends on view atestv3 +HINT: Use DROP ... CASCADE to drop the dependent objects too. +DROP TABLE atest4; +DROP TABLE atest5; +DROP TABLE atest6; +DROP TABLE atestc; +ERROR: table "atestc" does not exist +DROP TABLE atestp1; +DROP TABLE atestp2; +SELECT lo_unlink(oid) FROM pg_largeobject_metadata; + lo_unlink +----------- + 1 + 1 + 1 + 1 + 1 +(5 rows) + +DROP GROUP regressgroup1; +DROP GROUP regressgroup2; +ERROR: role "regressgroup2" cannot be dropped because some objects depend on it +DETAIL: privileges for table atest3 +-- these are needed to clean up permissions +REVOKE USAGE ON LANGUAGE sql FROM regressuser1; +DROP OWNED BY regressuser1; +ERROR: cannot drop desired object(s) because other objects depend on them +DETAIL: view atestv1 depends on table atest1 +view atestv2 depends on table atest2 +HINT: Use DROP ... CASCADE to drop the dependent objects too. +DROP USER regressuser1; +ERROR: role "regressuser1" cannot be dropped because some objects depend on it +DETAIL: owner of default privileges on new functions belonging to role regressuser1 +owner of table atest2 +owner of table atest1 +DROP USER regressuser2; +ERROR: role "regressuser2" cannot be dropped because some objects depend on it +DETAIL: privileges for view atestv4 +privileges for view atestv2 +privileges for table atest2 +privileges for table atest1 +DROP USER regressuser3; +ERROR: role "regressuser3" cannot be dropped because some objects depend on it +DETAIL: owner of view atestv3 +owner of view atestv2 +owner of view atestv1 +owner of table atest3 +privileges for table atest2 +privileges for table atest1 +DROP USER regressuser4; +ERROR: role "regressuser4" cannot be dropped because some objects depend on it +DETAIL: owner of view atestv4 +privileges for view atestv3 +privileges for view atestv1 +privileges for table atest2 +privileges for table atest1 +DROP USER regressuser5; +ERROR: role "regressuser5" cannot be dropped because some objects depend on it +DETAIL: privileges for table atest2 +DROP USER regressuser6; +ERROR: role "regressuser6" does not exist ----------------------------------------------------------------------- Summary of changes: .../expected/{privileges.out => privileges_1.out} | 166 +++++++++++++------- 1 files changed, 107 insertions(+), 59 deletions(-) copy src/test/regress/expected/{privileges.out => privileges_1.out} (87%) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-25 17:03:49
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 796bf6e4b113d356b7d725daa71d62835faf9c68 (commit) from ca673e251cd252aa997c9ac51b8f90d2788e8bac (commit) - Log ----------------------------------------------------------------- commit 796bf6e4b113d356b7d725daa71d62835faf9c68 Author: Michael P <mic...@us...> Date: Sat Mar 26 02:02:14 2011 +0900 Fix for regression test create type Postgres-XC does not support TEMP tables, so this output is correct. diff --git a/src/test/regress/expected/create_type_1.out b/src/test/regress/expected/create_type_1.out new file mode 100644 index 0000000..9317dd9 --- /dev/null +++ b/src/test/regress/expected/create_type_1.out @@ -0,0 +1,118 @@ +-- +-- CREATE_TYPE +-- +-- +-- Note: widget_in/out were created in create_function_1, without any +-- prior shell-type creation. These commands therefore complete a test +-- of the "old style" approach of making the functions first. +-- +CREATE TYPE widget ( + internallength = 24, + input = widget_in, + output = widget_out, + typmod_in = numerictypmodin, + typmod_out = numerictypmodout, + alignment = double +); +CREATE TYPE city_budget ( + internallength = 16, + input = int44in, + output = int44out, + element = int4, + category = 'x', -- just to verify the system will take it + preferred = true -- ditto +); +-- Test creation and destruction of shell types +CREATE TYPE shell; +CREATE TYPE shell; -- fail, type already present +ERROR: type "shell" already exists +DROP TYPE shell; +DROP TYPE shell; -- fail, type not exist +ERROR: type "shell" does not exist +-- +-- Test type-related default values (broken in releases before PG 7.2) +-- +-- This part of the test also exercises the "new style" approach of making +-- a shell type and then filling it in. +-- +CREATE TYPE int42; +CREATE TYPE text_w_default; +-- Make dummy I/O routines using the existing internal support for int4, text +CREATE FUNCTION int42_in(cstring) + RETURNS int42 + AS 'int4in' + LANGUAGE internal STRICT; +NOTICE: return type int42 is only a shell +CREATE FUNCTION int42_out(int42) + RETURNS cstring + AS 'int4out' + LANGUAGE internal STRICT; +NOTICE: argument type int42 is only a shell +CREATE FUNCTION text_w_default_in(cstring) + RETURNS text_w_default + AS 'textin' + LANGUAGE internal STRICT; +NOTICE: return type text_w_default is only a shell +CREATE FUNCTION text_w_default_out(text_w_default) + RETURNS cstring + AS 'textout' + LANGUAGE internal STRICT; +NOTICE: argument type text_w_default is only a shell +CREATE TYPE int42 ( + internallength = 4, + input = int42_in, + output = int42_out, + alignment = int4, + default = 42, + passedbyvalue +); +CREATE TYPE text_w_default ( + internallength = variable, + input = text_w_default_in, + output = text_w_default_out, + alignment = int4, + default = 'zippo' +); +CREATE TABLE default_test (f1 text_w_default, f2 int42); +INSERT INTO default_test DEFAULT VALUES; +SELECT * FROM default_test; + f1 | f2 +-------+---- + zippo | 42 +(1 row) + +-- Test stand-alone composite type +CREATE TYPE default_test_row AS (f1 text_w_default, f2 int42); +CREATE FUNCTION get_default_test() RETURNS SETOF default_test_row AS ' + SELECT * FROM default_test; +' LANGUAGE SQL; +SELECT * FROM get_default_test(); + f1 | f2 +-------+---- + zippo | 42 +(1 row) + +-- Test comments +COMMENT ON TYPE bad IS 'bad comment'; +ERROR: type "bad" does not exist +COMMENT ON TYPE default_test_row IS 'good comment'; +COMMENT ON TYPE default_test_row IS NULL; +-- Check shell type create for existing types +CREATE TYPE text_w_default; -- should fail +ERROR: type "text_w_default" already exists +DROP TYPE default_test_row CASCADE; +NOTICE: drop cascades to function get_default_test() +DROP TABLE default_test; +-- Check usage of typmod with a user-defined type +-- (we have borrowed numeric's typmod functions) +CREATE TEMP TABLE mytab (foo widget(42,13,7)); -- should fail +ERROR: invalid NUMERIC type modifier +LINE 1: CREATE TEMP TABLE mytab (foo widget(42,13,7)); + ^ +CREATE TEMP TABLE mytab (foo widget(42,13)); +ERROR: PG-XC does not yet support temporary tables +SELECT format_type(atttypid,atttypmod) FROM pg_attribute +WHERE attrelid = 'mytab'::regclass AND attnum > 0; +ERROR: relation "mytab" does not exist +LINE 2: WHERE attrelid = 'mytab'::regclass AND attnum > 0; + ^ ----------------------------------------------------------------------- Summary of changes: .../{create_type.out => create_type_1.out} | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-) copy src/test/regress/expected/{create_type.out => create_type_1.out} (95%) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-25 15:09:26
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via ca673e251cd252aa997c9ac51b8f90d2788e8bac (commit) via 76f1d9cde238be026007d00a6af192b7f7ac4ce5 (commit) from 8f2f50bd72fd570de84518eaf39abbf464de7019 (commit) - Log ----------------------------------------------------------------- commit ca673e251cd252aa997c9ac51b8f90d2788e8bac Author: Michael P <mic...@us...> Date: Sat Mar 26 00:07:26 2011 +0900 Addition of a check when fetching tuples A strange crash was happening in xmlmap. diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c index 0f3551c..a200628 100644 --- a/src/backend/utils/sort/tuplesort.c +++ b/src/backend/utils/sort/tuplesort.c @@ -2881,11 +2881,19 @@ getlen_datanode(Tuplesortstate *state, int tapenum, bool eofOK) * the node number is stored in combiner->tapenodes[tapenum]. * If connection is inactive and no buffered data we have EOF condition */ - int nodenum = conn ? conn->nodenum : combiner->tapenodes[tapenum]; + int nodenum; unsigned int len = 0; ListCell *lc; ListCell *prev = NULL; + /* May it ever happen ?! */ + if (!conn && !combiner->tapenodes) + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("Failed to fetch from data node cursor"))); + + nodenum = conn ? conn->nodenum : combiner->tapenodes[tapenum]; + /* * If there are buffered rows iterate over them and get first from * the requested tape commit 76f1d9cde238be026007d00a6af192b7f7ac4ce5 Author: Michael P <mic...@us...> Date: Fri Mar 25 21:12:42 2011 +0900 Fix for cache lookup bug for type With this fix, backend Datanode send back to remote Coordinator the type name and note the OID type to avoid type inconsistencies between nodes as Postgres-XC is a shared-nothing architecture. Patch idea is from Mason, base patch is from Benny, I just gathered all the ideas and improved the patch. diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index a5e811f..ad8c568 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -20,7 +20,10 @@ #include "libpq/pqformat.h" #include "tcop/pquery.h" #include "utils/lsyscache.h" - +#ifdef PGXC +#include "pgxc/pgxc.h" +#include "parser/parse_type.h" +#endif static void printtup_startup(DestReceiver *self, int operation, TupleDesc typeinfo); @@ -189,6 +192,20 @@ SendRowDescriptionMessage(TupleDesc typeinfo, List *targetlist, int16 *formats) int32 atttypmod = attrs[i]->atttypmod; pq_sendstring(&buf, NameStr(attrs[i]->attname)); + +#ifdef PGXC + /* + * Send the type name from a Postgres-XC Datanode backend. + * This preserves from OID inconsistencies as architecture is shared nothing. + */ + if (IS_PGXC_DATANODE && IsConnFromCoord()) + { + char *typename; + typename = typeTypeName(typeidType(atttypid)); + pq_sendstring(&buf, typename); + } +#endif + /* column ID info appears in protocol 3.0 and up */ if (proto >= 3) { diff --git a/src/backend/pgxc/pool/execRemote.c b/src/backend/pgxc/pool/execRemote.c index d517899..95f23f3 100644 --- a/src/backend/pgxc/pool/execRemote.c +++ b/src/backend/pgxc/pool/execRemote.c @@ -35,6 +35,7 @@ #include "utils/snapmgr.h" #include "pgxc/locator.h" #include "pgxc/pgxc.h" +#include "parser/parse_type.h" #define END_QUERY_TIMEOUT 20 #define DATA_NODE_FETCH_SIZE 1 @@ -405,10 +406,10 @@ create_tuple_desc(char *msg_body, size_t len) for (i = 1; i <= nattr; i++) { AttrNumber attnum; - char *attname; + char *attname; + char *typname; Oid oidtypeid; int32 typmod; - uint32 n32; attnum = (AttrNumber) i; @@ -417,28 +418,31 @@ create_tuple_desc(char *msg_body, size_t len) attname = msg_body; msg_body += strlen(attname) + 1; + /* type name */ + typname = msg_body; + msg_body += strlen(typname) + 1; + /* table OID, ignored */ msg_body += 4; /* column no, ignored */ msg_body += 2; - /* data type */ - memcpy(&n32, msg_body, 4); - oidtypeid = ntohl(n32); + /* data type OID, ignored */ msg_body += 4; /* type len, ignored */ msg_body += 2; - /* type mod */ - memcpy(&n32, msg_body, 4); - typmod = ntohl(n32); + /* type mod, ignored */ msg_body += 4; /* PGXCTODO text/binary flag? */ msg_body += 2; + /* Get the OID type and mode type from typename */ + parseTypeString(typname, &oidtypeid, &typmod); + TupleDescInitEntry(result, attnum, attname, oidtypeid, typmod, 0); } return result; ----------------------------------------------------------------------- Summary of changes: src/backend/access/common/printtup.c | 19 ++++++++++++++++++- src/backend/pgxc/pool/execRemote.c | 20 ++++++++++++-------- src/backend/utils/sort/tuplesort.c | 10 +++++++++- 3 files changed, 39 insertions(+), 10 deletions(-) hooks/post-receive -- Postgres-XC |
From: Abbas B. <ga...@us...> - 2011-03-25 10:44:55
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 8f2f50bd72fd570de84518eaf39abbf464de7019 (commit) from c696488cee189743e90303c52954f9e4d791e18c (commit) - Log ----------------------------------------------------------------- commit 8f2f50bd72fd570de84518eaf39abbf464de7019 Author: Abbas <abb...@en...> Date: Fri Mar 25 15:44:08 2011 +0500 Since the creation of unique indices is supposed to fail in XC hence this output is correct diff --git a/src/test/regress/expected/uuid_1.out b/src/test/regress/expected/uuid_1.out new file mode 100644 index 0000000..6a593be --- /dev/null +++ b/src/test/regress/expected/uuid_1.out @@ -0,0 +1,148 @@ +-- regression test for the uuid datatype +-- creating test tables +CREATE TABLE guid1 +( + guid_field UUID, + text_field TEXT DEFAULT(now()) +); +CREATE TABLE guid2 +( + guid_field UUID, + text_field TEXT DEFAULT(now()) +); +-- inserting invalid data tests +-- too long +INSERT INTO guid1(guid_field) VALUES('11111111-1111-1111-1111-111111111111F'); +ERROR: invalid input syntax for uuid: "11111111-1111-1111-1111-111111111111F" +LINE 1: INSERT INTO guid1(guid_field) VALUES('11111111-1111-1111-111... + ^ +-- too short +INSERT INTO guid1(guid_field) VALUES('{11111111-1111-1111-1111-11111111111}'); +ERROR: invalid input syntax for uuid: "{11111111-1111-1111-1111-11111111111}" +LINE 1: INSERT INTO guid1(guid_field) VALUES('{11111111-1111-1111-11... + ^ +-- valid data but invalid format +INSERT INTO guid1(guid_field) VALUES('111-11111-1111-1111-1111-111111111111'); +ERROR: invalid input syntax for uuid: "111-11111-1111-1111-1111-111111111111" +LINE 1: INSERT INTO guid1(guid_field) VALUES('111-11111-1111-1111-11... + ^ +INSERT INTO guid1(guid_field) VALUES('{22222222-2222-2222-2222-222222222222 '); +ERROR: invalid input syntax for uuid: "{22222222-2222-2222-2222-222222222222 " +LINE 1: INSERT INTO guid1(guid_field) VALUES('{22222222-2222-2222-22... + ^ +-- invalid data +INSERT INTO guid1(guid_field) VALUES('11111111-1111-1111-G111-111111111111'); +ERROR: invalid input syntax for uuid: "11111111-1111-1111-G111-111111111111" +LINE 1: INSERT INTO guid1(guid_field) VALUES('11111111-1111-1111-G11... + ^ +INSERT INTO guid1(guid_field) VALUES('11+11111-1111-1111-1111-111111111111'); +ERROR: invalid input syntax for uuid: "11+11111-1111-1111-1111-111111111111" +LINE 1: INSERT INTO guid1(guid_field) VALUES('11+11111-1111-1111-111... + ^ +--inserting three input formats +INSERT INTO guid1(guid_field) VALUES('11111111-1111-1111-1111-111111111111'); +INSERT INTO guid1(guid_field) VALUES('{22222222-2222-2222-2222-222222222222}'); +INSERT INTO guid1(guid_field) VALUES('3f3e3c3b3a3039383736353433a2313e'); +-- retrieving the inserted data +SELECT guid_field FROM guid1 ORDER BY guid_field; + guid_field +-------------------------------------- + 11111111-1111-1111-1111-111111111111 + 22222222-2222-2222-2222-222222222222 + 3f3e3c3b-3a30-3938-3736-353433a2313e +(3 rows) + +-- ordering test +SELECT guid_field FROM guid1 ORDER BY guid_field ASC; + guid_field +-------------------------------------- + 11111111-1111-1111-1111-111111111111 + 22222222-2222-2222-2222-222222222222 + 3f3e3c3b-3a30-3938-3736-353433a2313e +(3 rows) + +SELECT guid_field FROM guid1 ORDER BY guid_field DESC; + guid_field +-------------------------------------- + 3f3e3c3b-3a30-3938-3736-353433a2313e + 22222222-2222-2222-2222-222222222222 + 11111111-1111-1111-1111-111111111111 +(3 rows) + +-- = operator test +SELECT COUNT(*) FROM guid1 WHERE guid_field = '3f3e3c3b-3a30-3938-3736-353433a2313e'; + count +------- + 1 +(1 row) + +-- <> operator test +SELECT COUNT(*) FROM guid1 WHERE guid_field <> '11111111111111111111111111111111'; + count +------- + 2 +(1 row) + +-- < operator test +SELECT COUNT(*) FROM guid1 WHERE guid_field < '22222222-2222-2222-2222-222222222222'; + count +------- + 1 +(1 row) + +-- <= operator test +SELECT COUNT(*) FROM guid1 WHERE guid_field <= '22222222-2222-2222-2222-222222222222'; + count +------- + 2 +(1 row) + +-- > operator test +SELECT COUNT(*) FROM guid1 WHERE guid_field > '22222222-2222-2222-2222-222222222222'; + count +------- + 1 +(1 row) + +-- >= operator test +SELECT COUNT(*) FROM guid1 WHERE guid_field >= '22222222-2222-2222-2222-222222222222'; + count +------- + 2 +(1 row) + +-- btree and hash index creation test +CREATE INDEX guid1_btree ON guid1 USING BTREE (guid_field); +CREATE INDEX guid1_hash ON guid1 USING HASH (guid_field); +-- unique index test +CREATE UNIQUE INDEX guid1_unique_BTREE ON guid1 USING BTREE (guid_field); +ERROR: Cannot locally enforce a unique index on round robin distributed table. +-- should fail +INSERT INTO guid1(guid_field) VALUES('11111111-1111-1111-1111-111111111111'); +-- check to see whether the new indexes are actually there +SELECT count(*) FROM pg_class WHERE relkind='i' AND relname LIKE 'guid%'; + count +------- + 2 +(1 row) + +-- populating the test tables with additional records +INSERT INTO guid1(guid_field) VALUES('44444444-4444-4444-4444-444444444444'); +INSERT INTO guid2(guid_field) VALUES('11111111-1111-1111-1111-111111111111'); +INSERT INTO guid2(guid_field) VALUES('{22222222-2222-2222-2222-222222222222}'); +INSERT INTO guid2(guid_field) VALUES('3f3e3c3b3a3039383736353433a2313e'); +-- join test +SELECT COUNT(*) FROM guid1 g1 INNER JOIN guid2 g2 ON g1.guid_field = g2.guid_field; + count +------- + 4 +(1 row) + +SELECT COUNT(*) FROM guid1 g1 LEFT JOIN guid2 g2 ON g1.guid_field = g2.guid_field WHERE g2.guid_field IS NULL; + count +------- + 1 +(1 row) + +-- clean up +DROP TABLE guid1, guid2 CASCADE; ----------------------------------------------------------------------- Summary of changes: src/test/regress/expected/{uuid.out => uuid_1.out} | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) copy src/test/regress/expected/{uuid.out => uuid_1.out} (96%) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-24 16:44:52
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via c696488cee189743e90303c52954f9e4d791e18c (commit) from d12c17cc28433adedc44e63f5eb0f34b79c8523f (commit) - Log ----------------------------------------------------------------- commit c696488cee189743e90303c52954f9e4d791e18c Author: Michael P <mic...@us...> Date: Fri Mar 25 01:41:10 2011 +0900 Block DEFERRED constraints (DEFERRABLE) DEFERRED constraints are checked at transaction COMMIT. In a Postgres-XC transaction that involved DML failing on DEFERRED constraints, Datanodes return to Coordinator transaction errors, this was resulting in transaction partially committed in the cluster. In the case of pg_regress, test case constraints was putting the cluster in a stall state. IMMEDIATE constraints (default) are still available. diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index c8928f3..896ed43 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -3867,6 +3867,14 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt) if (afterTriggers == NULL) return; +#ifdef PGXC + if (stmt->deferred) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("Postgres-XC does not support DEFERRED constraints yet"), + errdetail("The feature is not currently supported"))); +#endif + /* * If in a subtransaction, and we didn't save the current state already, * save it so it can be restored if the subtransaction aborts. diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 6cfc1e6..21b5cfd 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -1345,6 +1345,15 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt) index->deferrable = constraint->deferrable; index->initdeferred = constraint->initdeferred; +#ifdef PGXC + /* DEFERRABLE INITIALLY DEFERRED constraints are not supported in Postgres-XC */ + if (constraint->deferrable && constraint->initdeferred) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("Postgres-XC does not support DEFERRED constraints yet"), + errdetail("The feature is not currently supported"))); +#endif + if (constraint->conname != NULL) index->idxname = pstrdup(constraint->conname); else @@ -2290,6 +2299,12 @@ transformConstraintAttrs(ParseState *pstate, List *constraintList) break; case CONSTR_ATTR_DEFERRED: +#ifdef PGXC + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("Postgres-XC does not support DEFERRED constraints yet"), + errdetail("The feature is not currently supported"))); +#endif if (!SUPPORTS_ATTRS(lastprimarycon)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), ----------------------------------------------------------------------- Summary of changes: src/backend/commands/trigger.c | 8 ++++++++ src/backend/parser/parse_utilcmd.c | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 0 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-24 14:44:39
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been deleted was 12b82128657ffc41a525828c1c1f5763f7b88cb9 ----------------------------------------------------------------------- 12b82128657ffc41a525828c1c1f5763f7b88cb9 This change will fix bug ID 3220353,a test case in strings.sql was failing because of missing handling for aliases in planner ----------------------------------------------------------------------- hooks/post-receive -- Postgres-XC |
From: Abbas B. <ga...@us...> - 2011-03-24 09:53:09
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 12b82128657ffc41a525828c1c1f5763f7b88cb9 (commit) from d12c17cc28433adedc44e63f5eb0f34b79c8523f (commit) - Log ----------------------------------------------------------------- commit 12b82128657ffc41a525828c1c1f5763f7b88cb9 Author: Abbas <abb...@en...> Date: Thu Mar 24 14:52:29 2011 +0500 This change will fix bug ID 3220353,a test case in strings.sql was failing because of missing handling for aliases in planner diff --git a/src/backend/pgxc/plan/planner.c b/src/backend/pgxc/plan/planner.c index e4d13cb..0d6d813 100644 --- a/src/backend/pgxc/plan/planner.c +++ b/src/backend/pgxc/plan/planner.c @@ -2244,6 +2244,10 @@ reconstruct_step_query(List *rtable, bool has_order_by, List *extra_sort, foreach(l, sub_tlist) { TargetEntry *tle = (TargetEntry *) lfirst(l); + + if (tle->resjunk) + continue; + char *exprstr = deparse_expression((Node *) tle->expr, context, useprefix, false); ----------------------------------------------------------------------- Summary of changes: src/backend/pgxc/plan/planner.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-24 09:48:47
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via d12c17cc28433adedc44e63f5eb0f34b79c8523f (commit) from d4b2b6421ffb3d443a2f9bf923b9615f4c5752fb (commit) - Log ----------------------------------------------------------------- commit d12c17cc28433adedc44e63f5eb0f34b79c8523f Author: Michael P <mic...@us...> Date: Thu Mar 24 18:47:29 2011 +0900 Fix for regression test truncate Postgres-XC does not support yet SERIAL, TRIGGER and INHERITS based on multiple parents for distributed tables, so this output is correct. diff --git a/src/test/regress/expected/truncate_1.out b/src/test/regress/expected/truncate_1.out new file mode 100644 index 0000000..4bccc4e --- /dev/null +++ b/src/test/regress/expected/truncate_1.out @@ -0,0 +1,418 @@ +-- Test basic TRUNCATE functionality. +CREATE TABLE truncate_a (col1 integer primary key); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "truncate_a_pkey" for table "truncate_a" +INSERT INTO truncate_a VALUES (1); +INSERT INTO truncate_a VALUES (2); +SELECT * FROM truncate_a ORDER BY 1; + col1 +------ + 1 + 2 +(2 rows) + +-- Roll truncate back +BEGIN; +TRUNCATE truncate_a; +ROLLBACK; +SELECT * FROM truncate_a ORDER BY 1; + col1 +------ + 1 + 2 +(2 rows) + +-- Commit the truncate this time +BEGIN; +TRUNCATE truncate_a; +COMMIT; +SELECT * FROM truncate_a ORDER BY 1; + col1 +------ +(0 rows) + +-- Test foreign-key checks +CREATE TABLE trunc_b (a int REFERENCES truncate_a); +CREATE TABLE trunc_c (a serial PRIMARY KEY); +ERROR: Postgres-XC does not support SERIAL yet +DETAIL: The feature is not currently supported +CREATE TABLE trunc_d (a int REFERENCES trunc_c); +ERROR: relation "trunc_c" does not exist +CREATE TABLE trunc_e (a int REFERENCES truncate_a, b int REFERENCES trunc_c); +ERROR: relation "trunc_c" does not exist +TRUNCATE TABLE truncate_a; -- fail +ERROR: cannot truncate a table referenced in a foreign key constraint +DETAIL: Table "trunc_b" references "truncate_a". +HINT: Truncate table "trunc_b" at the same time, or use TRUNCATE ... CASCADE. +TRUNCATE TABLE truncate_a,trunc_b; -- fail +TRUNCATE TABLE truncate_a,trunc_b,trunc_e; -- ok +ERROR: relation "trunc_e" does not exist +TRUNCATE TABLE truncate_a,trunc_e; -- fail +ERROR: relation "trunc_e" does not exist +TRUNCATE TABLE trunc_c; -- fail +ERROR: relation "trunc_c" does not exist +TRUNCATE TABLE trunc_c,trunc_d; -- fail +ERROR: relation "trunc_c" does not exist +TRUNCATE TABLE trunc_c,trunc_d,trunc_e; -- ok +ERROR: relation "trunc_c" does not exist +TRUNCATE TABLE trunc_c,trunc_d,trunc_e,truncate_a; -- fail +ERROR: relation "trunc_c" does not exist +TRUNCATE TABLE trunc_c,trunc_d,trunc_e,truncate_a,trunc_b; -- ok +ERROR: relation "trunc_c" does not exist +TRUNCATE TABLE truncate_a RESTRICT; -- fail +ERROR: cannot truncate a table referenced in a foreign key constraint +DETAIL: Table "trunc_b" references "truncate_a". +HINT: Truncate table "trunc_b" at the same time, or use TRUNCATE ... CASCADE. +TRUNCATE TABLE truncate_a CASCADE; -- ok +NOTICE: truncate cascades to table "trunc_b" +-- circular references +ALTER TABLE truncate_a ADD FOREIGN KEY (col1) REFERENCES trunc_c; +ERROR: relation "trunc_c" does not exist +-- Add some data to verify that truncating actually works ... +INSERT INTO trunc_c VALUES (1); +ERROR: relation "trunc_c" does not exist +LINE 1: INSERT INTO trunc_c VALUES (1); + ^ +INSERT INTO truncate_a VALUES (1); +INSERT INTO trunc_b VALUES (1); +INSERT INTO trunc_d VALUES (1); +ERROR: relation "trunc_d" does not exist +LINE 1: INSERT INTO trunc_d VALUES (1); + ^ +INSERT INTO trunc_e VALUES (1,1); +ERROR: relation "trunc_e" does not exist +LINE 1: INSERT INTO trunc_e VALUES (1,1); + ^ +TRUNCATE TABLE trunc_c; +ERROR: relation "trunc_c" does not exist +TRUNCATE TABLE trunc_c,truncate_a; +ERROR: relation "trunc_c" does not exist +TRUNCATE TABLE trunc_c,truncate_a,trunc_d; +ERROR: relation "trunc_c" does not exist +TRUNCATE TABLE trunc_c,truncate_a,trunc_d,trunc_e; +ERROR: relation "trunc_c" does not exist +TRUNCATE TABLE trunc_c,truncate_a,trunc_d,trunc_e,trunc_b; +ERROR: relation "trunc_c" does not exist +-- Verify that truncating did actually work +SELECT * FROM truncate_a + UNION ALL + SELECT * FROM trunc_c + UNION ALL + SELECT * FROM trunc_b + UNION ALL + SELECT * FROM trunc_d; +ERROR: relation "trunc_c" does not exist +LINE 3: SELECT * FROM trunc_c + ^ +SELECT * FROM trunc_e; +ERROR: relation "trunc_e" does not exist +LINE 1: SELECT * FROM trunc_e; + ^ +-- Add data again to test TRUNCATE ... CASCADE +INSERT INTO trunc_c VALUES (1); +ERROR: relation "trunc_c" does not exist +LINE 1: INSERT INTO trunc_c VALUES (1); + ^ +INSERT INTO truncate_a VALUES (1); +ERROR: duplicate key value violates unique constraint "truncate_a_pkey" +INSERT INTO trunc_b VALUES (1); +INSERT INTO trunc_d VALUES (1); +ERROR: relation "trunc_d" does not exist +LINE 1: INSERT INTO trunc_d VALUES (1); + ^ +INSERT INTO trunc_e VALUES (1,1); +ERROR: relation "trunc_e" does not exist +LINE 1: INSERT INTO trunc_e VALUES (1,1); + ^ +TRUNCATE TABLE trunc_c CASCADE; -- ok +ERROR: relation "trunc_c" does not exist +SELECT * FROM truncate_a + UNION ALL + SELECT * FROM trunc_c + UNION ALL + SELECT * FROM trunc_b + UNION ALL + SELECT * FROM trunc_d; +ERROR: relation "trunc_c" does not exist +LINE 3: SELECT * FROM trunc_c + ^ +SELECT * FROM trunc_e; +ERROR: relation "trunc_e" does not exist +LINE 1: SELECT * FROM trunc_e; + ^ +DROP TABLE truncate_a,trunc_c,trunc_b,trunc_d,trunc_e CASCADE; +ERROR: table "trunc_c" does not exist +-- Test TRUNCATE with inheritance +CREATE TABLE trunc_f (col1 integer primary key); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "trunc_f_pkey" for table "trunc_f" +INSERT INTO trunc_f VALUES (1); +INSERT INTO trunc_f VALUES (2); +CREATE TABLE trunc_fa (col2a text) INHERITS (trunc_f); +INSERT INTO trunc_fa VALUES (3, 'three'); +CREATE TABLE trunc_fb (col2b int) INHERITS (trunc_f); +INSERT INTO trunc_fb VALUES (4, 444); +CREATE TABLE trunc_faa (col3 text) INHERITS (trunc_fa); +INSERT INTO trunc_faa VALUES (5, 'five', 'FIVE'); +BEGIN; +SELECT * FROM trunc_f ORDER BY 1; + col1 +------ + 1 + 2 + 3 + 4 + 5 +(5 rows) + +TRUNCATE trunc_f; +SELECT * FROM trunc_f ORDER BY 1; + col1 +------ +(0 rows) + +ROLLBACK; +BEGIN; +SELECT * FROM trunc_f ORDER BY 1; + col1 +------ + 1 + 2 + 3 + 4 + 5 +(5 rows) + +TRUNCATE ONLY trunc_f; +SELECT * FROM trunc_f ORDER BY 1; + col1 +------ + 3 + 4 + 5 +(3 rows) + +ROLLBACK; +BEGIN; +SELECT * FROM trunc_f ORDER BY 1; + col1 +------ + 1 + 2 + 3 + 4 + 5 +(5 rows) + +SELECT * FROM trunc_fa ORDER BY 1, 2; + col1 | col2a +------+------- + 3 | three + 5 | five +(2 rows) + +SELECT * FROM trunc_faa ORDER BY 1, 2; + col1 | col2a | col3 +------+-------+------ + 5 | five | FIVE +(1 row) + +TRUNCATE ONLY trunc_fb, ONLY trunc_fa; +SELECT * FROM trunc_f ORDER BY 1; + col1 +------ + 1 + 2 + 5 +(3 rows) + +SELECT * FROM trunc_fa ORDER BY 1, 2; + col1 | col2a +------+------- + 5 | five +(1 row) + +SELECT * FROM trunc_faa ORDER BY 1, 2; + col1 | col2a | col3 +------+-------+------ + 5 | five | FIVE +(1 row) + +ROLLBACK; +BEGIN; +SELECT * FROM trunc_f ORDER BY 1; + col1 +------ + 1 + 2 + 3 + 4 + 5 +(5 rows) + +SELECT * FROM trunc_fa ORDER BY 1, 2; + col1 | col2a +------+------- + 3 | three + 5 | five +(2 rows) + +SELECT * FROM trunc_faa ORDER BY 1, 2; + col1 | col2a | col3 +------+-------+------ + 5 | five | FIVE +(1 row) + +TRUNCATE ONLY trunc_fb, trunc_fa; +SELECT * FROM trunc_f ORDER BY 1; + col1 +------ + 1 + 2 +(2 rows) + +SELECT * FROM trunc_fa ORDER BY 1, 2; + col1 | col2a +------+------- +(0 rows) + +SELECT * FROM trunc_faa ORDER BY 1, 2; + col1 | col2a | col3 +------+-------+------ +(0 rows) + +ROLLBACK; +DROP TABLE trunc_f CASCADE; +NOTICE: drop cascades to 3 other objects +DETAIL: drop cascades to table trunc_fa +drop cascades to table trunc_faa +drop cascades to table trunc_fb +-- Test ON TRUNCATE triggers +CREATE TABLE trunc_trigger_test (f1 int, f2 text, f3 text); +CREATE TABLE trunc_trigger_log (tgop text, tglevel text, tgwhen text, + tgargv text, tgtable name, rowcount bigint); +CREATE FUNCTION trunctrigger() RETURNS trigger as $$ +declare c bigint; +begin + execute 'select count(*) from ' || quote_ident(tg_table_name) into c; + insert into trunc_trigger_log values + (TG_OP, TG_LEVEL, TG_WHEN, TG_ARGV[0], tg_table_name, c); + return null; +end; +$$ LANGUAGE plpgsql; +-- basic before trigger +INSERT INTO trunc_trigger_test VALUES(1, 'foo', 'bar'), (2, 'baz', 'quux'); +CREATE TRIGGER t +BEFORE TRUNCATE ON trunc_trigger_test +FOR EACH STATEMENT +EXECUTE PROCEDURE trunctrigger('before trigger truncate'); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +SELECT count(*) as "Row count in test table" FROM trunc_trigger_test; + Row count in test table +------------------------- + 2 +(1 row) + +SELECT * FROM trunc_trigger_log; + tgop | tglevel | tgwhen | tgargv | tgtable | rowcount +------+---------+--------+--------+---------+---------- +(0 rows) + +TRUNCATE trunc_trigger_test; +SELECT count(*) as "Row count in test table" FROM trunc_trigger_test; + Row count in test table +------------------------- + 0 +(1 row) + +SELECT * FROM trunc_trigger_log; + tgop | tglevel | tgwhen | tgargv | tgtable | rowcount +------+---------+--------+--------+---------+---------- +(0 rows) + +DROP TRIGGER t ON trunc_trigger_test; +ERROR: trigger "t" for table "trunc_trigger_test" does not exist +truncate trunc_trigger_log; +-- same test with an after trigger +INSERT INTO trunc_trigger_test VALUES(1, 'foo', 'bar'), (2, 'baz', 'quux'); +CREATE TRIGGER tt +AFTER TRUNCATE ON trunc_trigger_test +FOR EACH STATEMENT +EXECUTE PROCEDURE trunctrigger('after trigger truncate'); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +SELECT count(*) as "Row count in test table" FROM trunc_trigger_test; + Row count in test table +------------------------- + 2 +(1 row) + +SELECT * FROM trunc_trigger_log; + tgop | tglevel | tgwhen | tgargv | tgtable | rowcount +------+---------+--------+--------+---------+---------- +(0 rows) + +TRUNCATE trunc_trigger_test; +SELECT count(*) as "Row count in test table" FROM trunc_trigger_test; + Row count in test table +------------------------- + 0 +(1 row) + +SELECT * FROM trunc_trigger_log; + tgop | tglevel | tgwhen | tgargv | tgtable | rowcount +------+---------+--------+--------+---------+---------- +(0 rows) + +DROP TABLE trunc_trigger_test; +DROP TABLE trunc_trigger_log; +DROP FUNCTION trunctrigger(); +-- test TRUNCATE ... RESTART IDENTITY +CREATE SEQUENCE truncate_a_id1 START WITH 33; +CREATE TABLE truncate_a (id serial, + id1 integer default nextval('truncate_a_id1')); +ERROR: Postgres-XC does not support SERIAL yet +DETAIL: The feature is not currently supported +ALTER SEQUENCE truncate_a_id1 OWNED BY truncate_a.id1; +ERROR: column "id1" of relation "truncate_a" does not exist +INSERT INTO truncate_a DEFAULT VALUES; +ERROR: null value in column "col1" violates not-null constraint +INSERT INTO truncate_a DEFAULT VALUES; +ERROR: null value in column "col1" violates not-null constraint +SELECT * FROM truncate_a ORDER BY id; +ERROR: column "id" does not exist +LINE 1: SELECT * FROM truncate_a ORDER BY id; + ^ +TRUNCATE truncate_a; +ERROR: cannot truncate a table referenced in a foreign key constraint +DETAIL: Table "trunc_b" references "truncate_a". +HINT: Truncate table "trunc_b" at the same time, or use TRUNCATE ... CASCADE. +INSERT INTO truncate_a DEFAULT VALUES; +ERROR: null value in column "col1" violates not-null constraint +INSERT INTO truncate_a DEFAULT VALUES; +ERROR: null value in column "col1" violates not-null constraint +SELECT * FROM truncate_a ORDER BY id; +ERROR: column "id" does not exist +LINE 1: SELECT * FROM truncate_a ORDER BY id; + ^ +TRUNCATE truncate_a RESTART IDENTITY; +ERROR: cannot truncate a table referenced in a foreign key constraint +DETAIL: Table "trunc_b" references "truncate_a". +HINT: Truncate table "trunc_b" at the same time, or use TRUNCATE ... CASCADE. +INSERT INTO truncate_a DEFAULT VALUES; +ERROR: null value in column "col1" violates not-null constraint +INSERT INTO truncate_a DEFAULT VALUES; +ERROR: null value in column "col1" violates not-null constraint +SELECT * FROM truncate_a ORDER BY id; +ERROR: column "id" does not exist +LINE 1: SELECT * FROM truncate_a ORDER BY id; + ^ +DROP TABLE truncate_a; +ERROR: cannot drop table truncate_a because other objects depend on it +DETAIL: constraint trunc_b_a_fkey on table trunc_b depends on table truncate_a +HINT: Use DROP ... CASCADE to drop the dependent objects too. +SELECT nextval('truncate_a_id1'); -- fail, seq should have been dropped + nextval +--------- + 33 +(1 row) + ----------------------------------------------------------------------- Summary of changes: .../expected/{truncate.out => truncate_1.out} | 173 +++++++++++--------- 1 files changed, 93 insertions(+), 80 deletions(-) copy src/test/regress/expected/{truncate.out => truncate_1.out} (71%) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-24 09:38:43
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been deleted was dadf2a7116e557d57fb1c2badf321c53d148ac63 ----------------------------------------------------------------------- dadf2a7116e557d57fb1c2badf321c53d148ac63 Fix for regression test without_oid ----------------------------------------------------------------------- hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-24 09:34:04
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via dadf2a7116e557d57fb1c2badf321c53d148ac63 (commit) from d4b2b6421ffb3d443a2f9bf923b9615f4c5752fb (commit) - Log ----------------------------------------------------------------- commit dadf2a7116e557d57fb1c2badf321c53d148ac63 Author: Michael P <mic...@us...> Date: Thu Mar 24 18:32:52 2011 +0900 Fix for regression test without_oid SERIAL and TRIGGER are not yet supported by Postgres-XC, so this output is correct. diff --git a/src/test/regress/expected/without_oid_1.out b/src/test/regress/expected/without_oid_1.out new file mode 100644 index 0000000..5c03a3e --- /dev/null +++ b/src/test/regress/expected/without_oid_1.out @@ -0,0 +1,111 @@ +-- +-- WITHOUT OID +-- +-- +-- This test tries to verify that WITHOUT OIDS actually saves space. +-- On machines where MAXALIGN is 8, WITHOUT OIDS may or may not save any +-- space, depending on the size of the tuple header + null bitmap. +-- As of 8.3 we need a null bitmap of 8 or less bits for the difference +-- to appear. +-- +CREATE TABLE wi (i INT, + n1 int, n2 int, n3 int, n4 int, + n5 int, n6 int, n7 int) WITH OIDS; +CREATE TABLE wo (i INT, + n1 int, n2 int, n3 int, n4 int, + n5 int, n6 int, n7 int) WITHOUT OIDS; +INSERT INTO wi VALUES (1); -- 1 +INSERT INTO wo SELECT i FROM wi; -- 1 +INSERT INTO wo SELECT i+1 FROM wi; -- 1+1=2 +INSERT INTO wi SELECT i+1 FROM wo; -- 1+2=3 +INSERT INTO wi SELECT i+3 FROM wi; -- 3+3=6 +INSERT INTO wo SELECT i+2 FROM wi; -- 2+6=8 +INSERT INTO wo SELECT i+8 FROM wo; -- 8+8=16 +INSERT INTO wi SELECT i+6 FROM wo; -- 6+16=22 +INSERT INTO wi SELECT i+22 FROM wi; -- 22+22=44 +INSERT INTO wo SELECT i+16 FROM wi; -- 16+44=60 +INSERT INTO wo SELECT i+60 FROM wo; -- 60+60=120 +INSERT INTO wi SELECT i+44 FROM wo; -- 44+120=164 +INSERT INTO wi SELECT i+164 FROM wi; -- 164+164=328 +INSERT INTO wo SELECT i+120 FROM wi; -- 120+328=448 +INSERT INTO wo SELECT i+448 FROM wo; -- 448+448=896 +INSERT INTO wi SELECT i+328 FROM wo; -- 328+896=1224 +INSERT INTO wi SELECT i+1224 FROM wi; -- 1224+1224=2448 +INSERT INTO wo SELECT i+896 FROM wi; -- 896+2448=3344 +INSERT INTO wo SELECT i+3344 FROM wo; -- 3344+3344=6688 +INSERT INTO wi SELECT i+2448 FROM wo; -- 2448+6688=9136 +INSERT INTO wo SELECT i+6688 FROM wi WHERE i<=2448; -- 6688+2448=9136 +SELECT count(oid) FROM wi; + count +------- + 1 +(1 row) + +-- should fail +SELECT count(oid) FROM wo; +ERROR: column "oid" does not exist +LINE 1: SELECT count(oid) FROM wo; + ^ +VACUUM ANALYZE wi; +VACUUM ANALYZE wo; +SELECT min(relpages) < max(relpages), min(reltuples) - max(reltuples) + FROM pg_class + WHERE relname IN ('wi', 'wo'); + ?column? | ?column? +----------+---------- + f | -3 +(1 row) + +DROP TABLE wi; +DROP TABLE wo; +-- +-- WITH / WITHOUT OIDS in CREATE TABLE AS +-- +CREATE TABLE create_table_test ( + a int, + b int +); +COPY create_table_test FROM stdin; +CREATE TABLE create_table_test2 WITH OIDS AS + SELECT a + b AS c1, a - b AS c2 FROM create_table_test; +ERROR: INTO clause not yet supported +CREATE TABLE create_table_test3 WITHOUT OIDS AS + SELECT a + b AS c1, a - b AS c2 FROM create_table_test; +ERROR: INTO clause not yet supported +SELECT count(oid) FROM create_table_test2; +ERROR: relation "create_table_test2" does not exist +LINE 1: SELECT count(oid) FROM create_table_test2; + ^ +-- should fail +SELECT count(oid) FROM create_table_test3; +ERROR: relation "create_table_test3" does not exist +LINE 1: SELECT count(oid) FROM create_table_test3; + ^ +PREPARE table_source(int) AS + SELECT a + b AS c1, a - b AS c2, $1 AS c3 FROM create_table_test; +ERROR: Postgres-XC does not support PREPARE yet +DETAIL: The feature is not currently supported +CREATE TABLE execute_with WITH OIDS AS EXECUTE table_source(1); +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +CREATE TABLE execute_without WITHOUT OIDS AS EXECUTE table_source(2); +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +SELECT count(oid) FROM execute_with; +ERROR: relation "execute_with" does not exist +LINE 1: SELECT count(oid) FROM execute_with; + ^ +-- should fail +SELECT count(oid) FROM execute_without; +ERROR: relation "execute_without" does not exist +LINE 1: SELECT count(oid) FROM execute_without; + ^ +DROP TABLE create_table_test; +DROP TABLE create_table_test2; +ERROR: table "create_table_test2" does not exist +DROP TABLE create_table_test3; +ERROR: table "create_table_test3" does not exist +DROP TABLE execute_with; +ERROR: table "execute_with" does not exist +DROP TABLE execute_without; +ERROR: table "execute_without" does not exist ----------------------------------------------------------------------- Summary of changes: .../{without_oid.out => without_oid_1.out} | 40 ++++++++++++-------- 1 files changed, 24 insertions(+), 16 deletions(-) copy src/test/regress/expected/{without_oid.out => without_oid_1.out} (75%) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-24 08:38:31
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via d4b2b6421ffb3d443a2f9bf923b9615f4c5752fb (commit) from 6fd26e495ab4f8503042d0cb92aa1fae1c9a4342 (commit) - Log ----------------------------------------------------------------- commit d4b2b6421ffb3d443a2f9bf923b9615f4c5752fb Author: Michael P <mic...@us...> Date: Thu Mar 24 17:36:31 2011 +0900 Fix for regression test copy2 SERIAL and TEMP table are not yet supported by Postgres-XC, so this output is correct. It may be necessary to write additional test cases for Postgres-XC in the case of copy. diff --git a/src/test/regress/expected/copy2_1.out b/src/test/regress/expected/copy2_1.out new file mode 100644 index 0000000..0e07e98 --- /dev/null +++ b/src/test/regress/expected/copy2_1.out @@ -0,0 +1,245 @@ +CREATE TEMP TABLE x ( + a serial, + b int, + c text not null default 'stuff', + d text, + e text +) WITH OIDS; +ERROR: Postgres-XC does not support SERIAL yet +DETAIL: The feature is not currently supported +CREATE FUNCTION fn_x_before () RETURNS TRIGGER AS ' + BEGIN + NEW.e := ''before trigger fired''::text; + return NEW; + END; +' LANGUAGE plpgsql; +CREATE FUNCTION fn_x_after () RETURNS TRIGGER AS ' + BEGIN + UPDATE x set e=''after trigger fired'' where c=''stuff''; + return NULL; + END; +' LANGUAGE plpgsql; +CREATE TRIGGER trg_x_after AFTER INSERT ON x +FOR EACH ROW EXECUTE PROCEDURE fn_x_after(); +ERROR: relation "x" does not exist +CREATE TRIGGER trg_x_before BEFORE INSERT ON x +FOR EACH ROW EXECUTE PROCEDURE fn_x_before(); +ERROR: relation "x" does not exist +COPY x (a, b, c, d, e) from stdin; +ERROR: relation "x" does not exist +9999 \N \\N \NN \N +invalid command \N +10000 21 31 41 51 +\. +invalid command \. +COPY x (b, d) from stdin; +ERROR: syntax error at or near "9999" +LINE 1: 9999 + ^ +1 test_1 +\. +invalid command \. +COPY x (b, d) from stdin; +ERROR: syntax error at or near "1" +LINE 1: 1 test_1 + ^ +2 test_2 +3 test_3 +4 test_4 +5 test_5 +\. +invalid command \. +COPY x (a, b, c, d, e) from stdin; +ERROR: syntax error at or near "2" +LINE 1: 2 test_2 + ^ +10001 22 32 42 52 +10002 23 33 43 53 +10003 24 34 44 54 +10004 25 35 45 55 +10005 26 36 46 56 +\. +invalid command \. +-- non-existent column in column list: should fail +COPY x (xyz) from stdin; +ERROR: syntax error at or near "10001" +LINE 1: 10001 22 32 42 52 + ^ +-- too many columns in column list: should fail +COPY x (a, b, c, d, e, d, c) from stdin; +ERROR: relation "x" does not exist +-- missing data: should fail +COPY x from stdin; +ERROR: relation "x" does not exist +\. +invalid command \. +COPY x from stdin; +ERROR: relation "x" does not exist +2000 230 23 23 +\. +invalid command \. +COPY x from stdin; +ERROR: syntax error at or near "2000" +LINE 1: 2000 230 23 23 + ^ +2001 231 \N \N +invalid command \N +\. +invalid command \. +-- extra data: should fail +COPY x from stdin; +ERROR: syntax error at or near "2001" +LINE 1: 2001 231 + ^ +2002 232 40 50 60 70 80 +\. +invalid command \. +-- various COPY options: delimiters, oids, NULL string +COPY x (b, c, d, e) from stdin with oids delimiter ',' null 'x'; +ERROR: syntax error at or near "2002" +LINE 1: 2002 232 40 50 60 70 80 + ^ +500000,x,45,80,90 +500001,x,\x,\\x,\\\x +invalid command \x, +500002,x,\,,\\\,,\\ +invalid command \,, +\. +invalid command \. +COPY x from stdin WITH DELIMITER AS ';' NULL AS ''; +ERROR: syntax error at or near "500000" +LINE 1: 500000,x,45,80,90 + ^ +3000;;c;; +ERROR: syntax error at or near "3000" +LINE 1: 3000; + ^ +ERROR: syntax error at or near "c" +LINE 1: c; + ^ +\. +invalid command \. +COPY x from stdin WITH DELIMITER AS ':' NULL AS E'\\X'; +ERROR: relation "x" does not exist +4000:\X:C:\X:\X +invalid command \X:C: +4001:1:empty:: +4002:2:null:\X:\X +invalid command \X: +4003:3:Backslash:\\:\\ +invalid command \ +4004:4:BackslashX:\\X:\\X +invalid command \ +4005:5:N:\N:\N +invalid command \N: +4006:6:BackslashN:\\N:\\N +invalid command \ +4007:7:XX:\XX:\XX +invalid command \XX: +4008:8:Delimiter:\::\: +\. +invalid command \. +-- check results of copy in +SELECT * FROM x ORDER BY a, b; +ERROR: syntax error at or near "4000" +LINE 1: 4000: + ^ +-- COPY w/ oids on a table w/o oids should fail +CREATE TABLE no_oids ( + a int, + b int +) WITHOUT OIDS; +INSERT INTO no_oids (a, b) VALUES (5, 10); +INSERT INTO no_oids (a, b) VALUES (20, 30); +-- should fail +COPY no_oids FROM stdin WITH OIDS; +ERROR: table "no_oids" does not have OIDs +COPY no_oids TO stdout WITH OIDS; +ERROR: table "no_oids" does not have OIDs +-- check copy out +COPY x TO stdout; +ERROR: relation "x" does not exist +COPY x (c, e) TO stdout; +ERROR: relation "x" does not exist +COPY x (b, e) TO stdout WITH NULL 'I''m null'; +ERROR: relation "x" does not exist +CREATE TEMP TABLE y ( + col1 text, + col2 text +); +ERROR: PG-XC does not yet support temporary tables +INSERT INTO y VALUES ('Jackson, Sam', E'\\h'); +ERROR: relation "y" does not exist +LINE 1: INSERT INTO y VALUES ('Jackson, Sam', E'\\h'); + ^ +INSERT INTO y VALUES ('It is "perfect".',E'\t'); +ERROR: relation "y" does not exist +LINE 1: INSERT INTO y VALUES ('It is "perfect".',E'\t'); + ^ +INSERT INTO y VALUES ('', NULL); +ERROR: relation "y" does not exist +LINE 1: INSERT INTO y VALUES ('', NULL); + ^ +COPY y TO stdout WITH CSV; +ERROR: relation "y" does not exist +COPY y TO stdout WITH CSV QUOTE '''' DELIMITER '|'; +ERROR: relation "y" does not exist +COPY y TO stdout WITH CSV FORCE QUOTE col2 ESCAPE E'\\'; +ERROR: relation "y" does not exist +COPY y TO stdout WITH CSV FORCE QUOTE *; +ERROR: relation "y" does not exist +-- Repeat above tests with new 9.0 option syntax +COPY y TO stdout (FORMAT CSV); +ERROR: relation "y" does not exist +COPY y TO stdout (FORMAT CSV, QUOTE '''', DELIMITER '|'); +ERROR: relation "y" does not exist +COPY y TO stdout (FORMAT CSV, FORCE_QUOTE (col2), ESCAPE E'\\'); +ERROR: relation "y" does not exist +COPY y TO stdout (FORMAT CSV, FORCE_QUOTE *); +ERROR: relation "y" does not exist +\copy y TO stdout (FORMAT CSV) +ERROR: relation "y" does not exist +\copy: ERROR: relation "y" does not exist +\copy y TO stdout (FORMAT CSV, QUOTE '''', DELIMITER '|') +ERROR: relation "y" does not exist +\copy: ERROR: relation "y" does not exist +\copy y TO stdout (FORMAT CSV, FORCE_QUOTE (col2), ESCAPE E'\\') +ERROR: relation "y" does not exist +\copy: ERROR: relation "y" does not exist +\copy y TO stdout (FORMAT CSV, FORCE_QUOTE *) +ERROR: relation "y" does not exist +\copy: ERROR: relation "y" does not exist +--test that we read consecutive LFs properly +CREATE TEMP TABLE testnl (a int, b text, c int); +ERROR: PG-XC does not yet support temporary tables +COPY testnl FROM stdin CSV; +ERROR: relation "testnl" does not exist +1,"a field with two LFs + +inside",2 +\. +invalid command \. +-- test end of copy marker +CREATE TEMP TABLE testeoc (a text); +ERROR: syntax error at or near "1" +LINE 1: 1,"a field with two LFs + ^ +COPY testeoc FROM stdin CSV; +ERROR: relation "testeoc" does not exist +a\. +invalid command \. +\.b +invalid command \.b +c\.d +invalid command \.d +"\." +\. +invalid command \. +COPY testeoc TO stdout CSV; +ERROR: syntax error at or near "a" +LINE 1: a + ^ +DROP TABLE x, y; +ERROR: table "x" does not exist +DROP FUNCTION fn_x_before(); +DROP FUNCTION fn_x_after(); ----------------------------------------------------------------------- Summary of changes: src/test/regress/expected/copy2_1.out | 245 +++++++++++++++++++++++++++++++++ 1 files changed, 245 insertions(+), 0 deletions(-) create mode 100644 src/test/regress/expected/copy2_1.out hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-23 14:25:33
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 6fd26e495ab4f8503042d0cb92aa1fae1c9a4342 (commit) from d759db01c235ccce001e86fbc7e6c211d63cb489 (commit) - Log ----------------------------------------------------------------- commit 6fd26e495ab4f8503042d0cb92aa1fae1c9a4342 Author: Michael P <mic...@us...> Date: Wed Mar 23 23:24:01 2011 +0900 Fix for regression test select_into onek2 is a table having 2 parents and Postgres-XC does not allow it, and tmp1 is a table create with INTO clause, also not supported, so this output is correct. diff --git a/src/test/regress/expected/select_into_1.out b/src/test/regress/expected/select_into_1.out new file mode 100644 index 0000000..3ef82f6 --- /dev/null +++ b/src/test/regress/expected/select_into_1.out @@ -0,0 +1,19 @@ +-- +-- SELECT_INTO +-- +SELECT * + INTO TABLE tmp1 + FROM onek + WHERE onek.unique1 < 2; +ERROR: INTO clause not yet supported +DROP TABLE tmp1; +ERROR: table "tmp1" does not exist +SELECT * + INTO TABLE tmp1 + FROM onek2 + WHERE onek2.unique1 < 2; +ERROR: relation "onek2" does not exist +LINE 3: FROM onek2 + ^ +DROP TABLE tmp1; +ERROR: table "tmp1" does not exist ----------------------------------------------------------------------- Summary of changes: src/test/regress/expected/select_into_1.out | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) create mode 100644 src/test/regress/expected/select_into_1.out hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-23 13:25:02
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via d759db01c235ccce001e86fbc7e6c211d63cb489 (commit) from 829cc54f2997a28979812ea057b084a4c3d5e8e9 (commit) - Log ----------------------------------------------------------------- commit d759db01c235ccce001e86fbc7e6c211d63cb489 Author: Michael P <mic...@us...> Date: Wed Mar 23 22:24:16 2011 +0900 Fix for regression test returning Error message for SERIAL tables has changed. diff --git a/src/test/regress/expected/returning_1.out b/src/test/regress/expected/returning_1.out index 42be497..c620a6a 100644 --- a/src/test/regress/expected/returning_1.out +++ b/src/test/regress/expected/returning_1.out @@ -3,8 +3,8 @@ -- -- 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 +ERROR: Postgres-XC does not support SERIAL yet +DETAIL: The feature is not currently supported INSERT INTO foo (f2,f3) VALUES ('test', DEFAULT), ('More', 11), (upper('more'), 7+9) RETURNING *, f1+f3 AS sum; ----------------------------------------------------------------------- Summary of changes: src/test/regress/expected/returning_1.out | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-23 13:22:36
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 829cc54f2997a28979812ea057b084a4c3d5e8e9 (commit) from c46b3fd73fb59f81f7887365c3399a1abd77f6b3 (commit) - Log ----------------------------------------------------------------- commit 829cc54f2997a28979812ea057b084a4c3d5e8e9 Author: Michael P <mic...@us...> Date: Wed Mar 23 22:20:52 2011 +0900 Fix for regression test rowtypes SERIAL tables and TEMP tables are not supported yet by Postgres-XC, so this output is correct. diff --git a/src/test/regress/expected/rowtypes_1.out b/src/test/regress/expected/rowtypes_1.out new file mode 100644 index 0000000..a6e532a --- /dev/null +++ b/src/test/regress/expected/rowtypes_1.out @@ -0,0 +1,323 @@ +-- +-- ROWTYPES +-- +-- Make both a standalone composite type and a table rowtype +create type complex as (r float8, i float8); +create temp table fullname (first text, last text); +ERROR: PG-XC does not yet support temporary tables +-- Nested composite +create type quad as (c1 complex, c2 complex); +-- Some simple tests of I/O conversions and row construction +select (1.1,2.2)::complex, row((3.3,4.4),(5.5,null))::quad; + row | row +-----------+------------------------ + (1.1,2.2) | ("(3.3,4.4)","(5.5,)") +(1 row) + +select row('Joe', 'Blow')::fullname, '(Joe,Blow)'::fullname; +ERROR: type "fullname" does not exist +LINE 1: select row('Joe', 'Blow')::fullname, '(Joe,Blow)'::fullname; + ^ +select '(Joe,von Blow)'::fullname, '(Joe,d''Blow)'::fullname; +ERROR: type "fullname" does not exist +LINE 1: select '(Joe,von Blow)'::fullname, '(Joe,d''Blow)'::fullname... + ^ +select '(Joe,"von""Blow")'::fullname, E'(Joe,d\\\\Blow)'::fullname; +ERROR: type "fullname" does not exist +LINE 1: select '(Joe,"von""Blow")'::fullname, E'(Joe,d\\\\Blow)'::fu... + ^ +select '(Joe,"Blow,Jr")'::fullname; +ERROR: type "fullname" does not exist +LINE 1: select '(Joe,"Blow,Jr")'::fullname; + ^ +select '(Joe,)'::fullname; -- ok, null 2nd column +ERROR: type "fullname" does not exist +LINE 1: select '(Joe,)'::fullname; + ^ +select '(Joe)'::fullname; -- bad +ERROR: type "fullname" does not exist +LINE 1: select '(Joe)'::fullname; + ^ +select '(Joe,,)'::fullname; -- bad +ERROR: type "fullname" does not exist +LINE 1: select '(Joe,,)'::fullname; + ^ +create temp table quadtable(f1 int, q quad); +ERROR: PG-XC does not yet support temporary tables +insert into quadtable values (1, ((3.3,4.4),(5.5,6.6))); +ERROR: relation "quadtable" does not exist +LINE 1: insert into quadtable values (1, ((3.3,4.4),(5.5,6.6))); + ^ +insert into quadtable values (2, ((null,4.4),(5.5,6.6))); +ERROR: relation "quadtable" does not exist +LINE 1: insert into quadtable values (2, ((null,4.4),(5.5,6.6))); + ^ +select * from quadtable order by f1, q; +ERROR: relation "quadtable" does not exist +LINE 1: select * from quadtable order by f1, q; + ^ +select f1, q.c1 from quadtable; -- fails, q is a table reference +ERROR: relation "quadtable" does not exist +LINE 1: select f1, q.c1 from quadtable; + ^ +select f1, (q).c1, (qq.q).c1.i from quadtable qq order by 1; +ERROR: relation "quadtable" does not exist +LINE 1: select f1, (q).c1, (qq.q).c1.i from quadtable qq order by 1; + ^ +create temp table people (fn fullname, bd date); +ERROR: type "fullname" does not exist +LINE 1: create temp table people (fn fullname, bd date); + ^ +insert into people values ('(Joe,Blow)', '1984-01-10'); +ERROR: relation "people" does not exist +LINE 1: insert into people values ('(Joe,Blow)', '1984-01-10'); + ^ +select * from people; +ERROR: relation "people" does not exist +LINE 1: select * from people; + ^ +-- at the moment this will not work due to ALTER TABLE inadequacy: +alter table fullname add column suffix text default ''; +ERROR: relation "fullname" does not exist +-- but this should work: +alter table fullname add column suffix text default null; +ERROR: relation "fullname" does not exist +select * from people; +ERROR: relation "people" does not exist +LINE 1: select * from people; + ^ +-- test insertion/updating of subfields +update people set fn.suffix = 'Jr'; +ERROR: relation "people" does not exist +LINE 1: update people set fn.suffix = 'Jr'; + ^ +select * from people; +ERROR: relation "people" does not exist +LINE 1: select * from people; + ^ +insert into quadtable (f1, q.c1.r, q.c2.i) values(44,55,66); +ERROR: relation "quadtable" does not exist +LINE 1: insert into quadtable (f1, q.c1.r, q.c2.i) values(44,55,66); + ^ +select * from quadtable order by f1, q; +ERROR: relation "quadtable" does not exist +LINE 1: select * from quadtable order by f1, q; + ^ +-- The object here is to ensure that toasted references inside +-- composite values don't cause problems. The large f1 value will +-- be toasted inside pp, it must still work after being copied to people. +create temp table pp (f1 text); +ERROR: PG-XC does not yet support temporary tables +insert into pp values (repeat('abcdefghijkl', 100000)); +ERROR: relation "pp" does not exist +LINE 1: insert into pp values (repeat('abcdefghijkl', 100000)); + ^ +insert into people select ('Jim', f1, null)::fullname, current_date from pp; +ERROR: relation "people" does not exist +LINE 1: insert into people select ('Jim', f1, null)::fullname, curre... + ^ +select (fn).first, substr((fn).last, 1, 20), length((fn).last) from people order by 1, 2; +ERROR: relation "people" does not exist +LINE 1: ... substr((fn).last, 1, 20), length((fn).last) from people ord... + ^ +-- Test row comparison semantics. Prior to PG 8.2 we did this in a totally +-- non-spec-compliant way. +select ROW(1,2) < ROW(1,3) as true; + true +------ + t +(1 row) + +select ROW(1,2) < ROW(1,1) as false; + false +------- + f +(1 row) + +select ROW(1,2) < ROW(1,NULL) as null; + null +------ + +(1 row) + +select ROW(1,2,3) < ROW(1,3,NULL) as true; -- the NULL is not examined + true +------ + t +(1 row) + +select ROW(11,'ABC') < ROW(11,'DEF') as true; + true +------ + t +(1 row) + +select ROW(11,'ABC') > ROW(11,'DEF') as false; + false +------- + f +(1 row) + +select ROW(12,'ABC') > ROW(11,'DEF') as true; + true +------ + t +(1 row) + +-- = and <> have different NULL-behavior than < etc +select ROW(1,2,3) < ROW(1,NULL,4) as null; + null +------ + +(1 row) + +select ROW(1,2,3) = ROW(1,NULL,4) as false; + false +------- + f +(1 row) + +select ROW(1,2,3) <> ROW(1,NULL,4) as true; + true +------ + t +(1 row) + +-- We allow operators beyond the six standard ones, if they have btree +-- operator classes. +select ROW('ABC','DEF') ~<=~ ROW('DEF','ABC') as true; + true +------ + t +(1 row) + +select ROW('ABC','DEF') ~>=~ ROW('DEF','ABC') as false; + false +------- + f +(1 row) + +select ROW('ABC','DEF') ~~ ROW('DEF','ABC') as fail; +ERROR: could not determine interpretation of row comparison operator ~~ +LINE 1: select ROW('ABC','DEF') ~~ ROW('DEF','ABC') as fail; + ^ +HINT: Row comparison operators must be associated with btree operator families. +-- Check row comparison with a subselect +select unique1, unique2 from tenk1 +where (unique1, unique2) < any (select ten, ten from tenk1 where hundred < 3) + and unique1 <= 20 +order by 1; + unique1 | unique2 +---------+--------- + 0 | 9998 + 1 | 2838 +(2 rows) + +-- Also check row comparison with an indexable condition +select thousand, tenthous from tenk1 +where (thousand, tenthous) >= (997, 5000) +order by thousand, tenthous; + thousand | tenthous +----------+---------- + 997 | 5997 + 997 | 6997 + 997 | 7997 + 997 | 8997 + 997 | 9997 + 998 | 998 + 998 | 1998 + 998 | 2998 + 998 | 3998 + 998 | 4998 + 998 | 5998 + 998 | 6998 + 998 | 7998 + 998 | 8998 + 998 | 9998 + 999 | 999 + 999 | 1999 + 999 | 2999 + 999 | 3999 + 999 | 4999 + 999 | 5999 + 999 | 6999 + 999 | 7999 + 999 | 8999 + 999 | 9999 +(25 rows) + +-- Check some corner cases involving empty rowtypes +select ROW(); + row +----- + () +(1 row) + +select ROW() IS NULL; + ?column? +---------- + t +(1 row) + +select ROW() = ROW(); +ERROR: cannot compare rows of zero length +LINE 1: select ROW() = ROW(); + ^ +-- Check ability to create arrays of anonymous rowtypes +select array[ row(1,2), row(3,4), row(5,6) ]; + array +--------------------------- + {"(1,2)","(3,4)","(5,6)"} +(1 row) + +-- Check ability to compare an anonymous row to elements of an array +select row(1,1.1) = any (array[ row(7,7.7), row(1,1.1), row(0,0.0) ]); + ?column? +---------- + t +(1 row) + +select row(1,1.1) = any (array[ row(7,7.7), row(1,1.0), row(0,0.0) ]); + ?column? +---------- + f +(1 row) + +-- +-- Test case derived from bug #5716: check multiple uses of a rowtype result +-- +BEGIN; +CREATE TABLE price ( + id SERIAL PRIMARY KEY, + active BOOLEAN NOT NULL, + price NUMERIC +); +ERROR: Postgres-XC does not support SERIAL yet +DETAIL: The feature is not currently supported +CREATE TYPE price_input AS ( + id INTEGER, + price NUMERIC +); +ERROR: current transaction is aborted, commands ignored until end of transaction block +CREATE TYPE price_key AS ( + id INTEGER +); +ERROR: current transaction is aborted, commands ignored until end of transaction block +CREATE FUNCTION price_key_from_table(price) RETURNS price_key AS $$ + SELECT $1.id +$$ LANGUAGE SQL; +ERROR: current transaction is aborted, commands ignored until end of transaction block +CREATE FUNCTION price_key_from_input(price_input) RETURNS price_key AS $$ + SELECT $1.id +$$ LANGUAGE SQL; +ERROR: current transaction is aborted, commands ignored until end of transaction block +insert into price values (1,false,42), (10,false,100), (11,true,17.99); +ERROR: current transaction is aborted, commands ignored until end of transaction block +UPDATE price + SET active = true, price = input_prices.price + FROM unnest(ARRAY[(10, 123.00), (11, 99.99)]::price_input[]) input_prices + WHERE price_key_from_table(price.*) = price_key_from_input(input_prices.*); +ERROR: current transaction is aborted, commands ignored until end of transaction block +select * from price; +ERROR: current transaction is aborted, commands ignored until end of transaction block +rollback; ----------------------------------------------------------------------- Summary of changes: .../expected/{rowtypes.out => rowtypes_1.out} | 163 ++++++++++---------- 1 files changed, 80 insertions(+), 83 deletions(-) copy src/test/regress/expected/{rowtypes.out => rowtypes_1.out} (63%) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-23 10:44:05
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via c46b3fd73fb59f81f7887365c3399a1abd77f6b3 (commit) from 2b2cc8ef94673ee9d68c6b36cd940c98b0960273 (commit) - Log ----------------------------------------------------------------- commit c46b3fd73fb59f81f7887365c3399a1abd77f6b3 Author: Michael P <mic...@us...> Date: Wed Mar 23 19:43:11 2011 +0900 Fix for regression test dependency SERIAL table is not supported yet by Postgres-XC, so this output is correct. diff --git a/src/test/regress/expected/dependency_1.out b/src/test/regress/expected/dependency_1.out new file mode 100644 index 0000000..ecf687d --- /dev/null +++ b/src/test/regress/expected/dependency_1.out @@ -0,0 +1,126 @@ +-- +-- DEPENDENCIES +-- +CREATE USER regression_user; +CREATE USER regression_user2; +CREATE USER regression_user3; +CREATE GROUP regression_group; +CREATE TABLE deptest (f1 serial primary key, f2 text); +ERROR: Postgres-XC does not support SERIAL yet +DETAIL: The feature is not currently supported +GRANT SELECT ON TABLE deptest TO GROUP regression_group; +ERROR: relation "deptest" does not exist +GRANT ALL ON TABLE deptest TO regression_user, regression_user2; +ERROR: relation "deptest" does not exist +-- can't drop neither because they have privileges somewhere +DROP USER regression_user; +DROP GROUP regression_group; +-- if we revoke the privileges we can drop the group +REVOKE SELECT ON deptest FROM GROUP regression_group; +ERROR: relation "deptest" does not exist +DROP GROUP regression_group; +ERROR: role "regression_group" does not exist +-- can't drop the user if we revoke the privileges partially +REVOKE SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES ON deptest FROM regression_user; +ERROR: relation "deptest" does not exist +DROP USER regression_user; +ERROR: role "regression_user" does not exist +-- now we are OK to drop him +REVOKE TRIGGER ON deptest FROM regression_user; +ERROR: relation "deptest" does not exist +DROP USER regression_user; +ERROR: role "regression_user" does not exist +-- we are OK too if we drop the privileges all at once +REVOKE ALL ON deptest FROM regression_user2; +ERROR: relation "deptest" does not exist +DROP USER regression_user2; +-- can't drop the owner of an object +-- the error message detail here would include a pg_toast_nnn name that +-- is not constant, so suppress it +\set VERBOSITY terse +ALTER TABLE deptest OWNER TO regression_user3; +ERROR: relation "deptest" does not exist +DROP USER regression_user3; +\set VERBOSITY default +-- if we drop the object, we can drop the user too +DROP TABLE deptest; +ERROR: table "deptest" does not exist +DROP USER regression_user3; +ERROR: role "regression_user3" does not exist +-- Test DROP OWNED +CREATE USER regression_user0; +CREATE USER regression_user1; +CREATE USER regression_user2; +SET SESSION AUTHORIZATION regression_user0; +-- permission denied +DROP OWNED BY regression_user1; +ERROR: permission denied to drop objects +DROP OWNED BY regression_user0, regression_user2; +ERROR: permission denied to drop objects +REASSIGN OWNED BY regression_user0 TO regression_user1; +ERROR: permission denied to reassign objects +REASSIGN OWNED BY regression_user1 TO regression_user0; +ERROR: permission denied to reassign objects +-- this one is allowed +DROP OWNED BY regression_user0; +CREATE TABLE deptest1 (f1 int unique); +NOTICE: CREATE TABLE / UNIQUE will create implicit index "deptest1_f1_key" for table "deptest1" +GRANT ALL ON deptest1 TO regression_user1 WITH GRANT OPTION; +SET SESSION AUTHORIZATION regression_user1; +CREATE TABLE deptest (a serial primary key, b text); +ERROR: Postgres-XC does not support SERIAL yet +DETAIL: The feature is not currently supported +GRANT ALL ON deptest1 TO regression_user2; +RESET SESSION AUTHORIZATION; +\z deptest1 + Access privileges + Schema | Name | Type | Access privileges | Column access privileges +--------+----------+-------+--------------------------------------------------+-------------------------- + public | deptest1 | table | regression_user0=arwdDxt/regression_user0 +| + | | | regression_user1=a*r*w*d*D*x*t*/regression_user0+| + | | | regression_user2=arwdDxt/regression_user1 | +(1 row) + +DROP OWNED BY regression_user1; +-- all grants revoked +\z deptest1 + Access privileges + Schema | Name | Type | Access privileges | Column access privileges +--------+----------+-------+-------------------------------------------+-------------------------- + public | deptest1 | table | regression_user0=arwdDxt/regression_user0 | +(1 row) + +-- table was dropped +\d deptest +-- Test REASSIGN OWNED +GRANT ALL ON deptest1 TO regression_user1; +SET SESSION AUTHORIZATION regression_user1; +CREATE TABLE deptest (a serial primary key, b text); +ERROR: Postgres-XC does not support SERIAL yet +DETAIL: The feature is not currently supported +CREATE TABLE deptest2 (f1 int); +-- make a serial column the hard way +CREATE SEQUENCE ss1; +ALTER TABLE deptest2 ALTER f1 SET DEFAULT nextval('ss1'); +ERROR: relation "ss1" does not exist +ALTER SEQUENCE ss1 OWNED BY deptest2.f1; +RESET SESSION AUTHORIZATION; +REASSIGN OWNED BY regression_user1 TO regression_user2; +\dt deptest + List of relations + Schema | Name | Type | Owner +--------+------+------+------- +(0 rows) + +-- doesn't work: grant still exists +DROP USER regression_user1; +ERROR: role "regression_user1" cannot be dropped because some objects depend on it +DETAIL: privileges for table deptest1 +DROP OWNED BY regression_user1; +DROP USER regression_user1; +\set VERBOSITY terse +DROP USER regression_user2; +ERROR: role "regression_user2" cannot be dropped because some objects depend on it +DROP OWNED BY regression_user2, regression_user0; +DROP USER regression_user2; +DROP USER regression_user0; ----------------------------------------------------------------------- Summary of changes: .../expected/{dependency.out => dependency_1.out} | 41 +++++++++++--------- 1 files changed, 23 insertions(+), 18 deletions(-) copy src/test/regress/expected/{dependency.out => dependency_1.out} (77%) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-23 10:38:30
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 2b2cc8ef94673ee9d68c6b36cd940c98b0960273 (commit) from 6b7c2fee9839c195d5d19be2d1e8457b7125fbd7 (commit) - Log ----------------------------------------------------------------- commit 2b2cc8ef94673ee9d68c6b36cd940c98b0960273 Author: Michael P <mic...@us...> Date: Wed Mar 23 19:37:34 2011 +0900 Fix for regression test cluster SERIAL table is not supported yet in Postgres-XC, so this output is correct. diff --git a/src/test/regress/expected/cluster_1.out b/src/test/regress/expected/cluster_1.out new file mode 100644 index 0000000..71eca00 --- /dev/null +++ b/src/test/regress/expected/cluster_1.out @@ -0,0 +1,395 @@ +-- +-- CLUSTER +-- +CREATE TABLE clstr_tst_s (rf_a SERIAL PRIMARY KEY, + b INT); +ERROR: Postgres-XC does not support SERIAL yet +DETAIL: The feature is not currently supported +CREATE TABLE clstr_tst (a SERIAL PRIMARY KEY, + b INT, + c TEXT, + d TEXT, + CONSTRAINT clstr_tst_con FOREIGN KEY (b) REFERENCES clstr_tst_s); +ERROR: Postgres-XC does not support SERIAL yet +DETAIL: The feature is not currently supported +CREATE INDEX clstr_tst_b ON clstr_tst (b); +ERROR: relation "clstr_tst" does not exist +CREATE INDEX clstr_tst_c ON clstr_tst (c); +ERROR: relation "clstr_tst" does not exist +CREATE INDEX clstr_tst_c_b ON clstr_tst (c,b); +ERROR: relation "clstr_tst" does not exist +CREATE INDEX clstr_tst_b_c ON clstr_tst (b,c); +ERROR: relation "clstr_tst" does not exist +INSERT INTO clstr_tst_s (b) VALUES (0); +ERROR: relation "clstr_tst_s" does not exist +LINE 1: INSERT INTO clstr_tst_s (b) VALUES (0); + ^ +INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s; +ERROR: relation "clstr_tst_s" does not exist +LINE 1: INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s; + ^ +INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s; +ERROR: relation "clstr_tst_s" does not exist +LINE 1: INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s; + ^ +INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s; +ERROR: relation "clstr_tst_s" does not exist +LINE 1: INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s; + ^ +INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s; +ERROR: relation "clstr_tst_s" does not exist +LINE 1: INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s; + ^ +INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s; +ERROR: relation "clstr_tst_s" does not exist +LINE 1: INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s; + ^ +CREATE TABLE clstr_tst_inh () INHERITS (clstr_tst); +ERROR: relation "clstr_tst" does not exist +INSERT INTO clstr_tst (b, c) VALUES (11, 'once'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (11, 'once'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (10, 'diez'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (10, 'diez'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (31, 'treinta y uno'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (31, 'treinta y uno'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (22, 'veintidos'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (22, 'veintidos'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (3, 'tres'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (3, 'tres'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (20, 'veinte'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (20, 'veinte'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (23, 'veintitres'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (23, 'veintitres'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (21, 'veintiuno'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (21, 'veintiuno'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (4, 'cuatro'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (4, 'cuatro'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (14, 'catorce'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (14, 'catorce'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (2, 'dos'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (2, 'dos'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (18, 'dieciocho'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (18, 'dieciocho'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (27, 'veintisiete'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (27, 'veintisiete'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (25, 'veinticinco'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (25, 'veinticinco'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (13, 'trece'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (13, 'trece'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (28, 'veintiocho'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (28, 'veintiocho'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (32, 'treinta y dos'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (32, 'treinta y dos'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (5, 'cinco'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (5, 'cinco'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (29, 'veintinueve'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (29, 'veintinueve'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (1, 'uno'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (1, 'uno'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (24, 'veinticuatro'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (24, 'veinticuatro'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (30, 'treinta'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (30, 'treinta'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (12, 'doce'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (12, 'doce'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (17, 'diecisiete'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (17, 'diecisiete'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (9, 'nueve'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (9, 'nueve'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (19, 'diecinueve'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (19, 'diecinueve'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (26, 'veintiseis'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (26, 'veintiseis'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (15, 'quince'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (15, 'quince'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (7, 'siete'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (7, 'siete'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (16, 'dieciseis'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (16, 'dieciseis'); + ^ +INSERT INTO clstr_tst (b, c) VALUES (8, 'ocho'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (8, 'ocho'); + ^ +-- This entry is needed to test that TOASTED values are copied correctly. +INSERT INTO clstr_tst (b, c, d) VALUES (6, 'seis', repeat('xyzzy', 100000)); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c, d) VALUES (6, 'seis', repeat('x... + ^ +CLUSTER clstr_tst_c ON clstr_tst; +ERROR: relation "clstr_tst" does not exist +SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY a, b, c; +ERROR: relation "clstr_tst" does not exist +LINE 1: SELECT a,b,c,substring(d for 30), length(d) from clstr_tst O... + ^ +SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY a; +ERROR: relation "clstr_tst" does not exist +LINE 1: SELECT a,b,c,substring(d for 30), length(d) from clstr_tst O... + ^ +SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY b; +ERROR: relation "clstr_tst" does not exist +LINE 1: SELECT a,b,c,substring(d for 30), length(d) from clstr_tst O... + ^ +SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY c; +ERROR: relation "clstr_tst" does not exist +LINE 1: SELECT a,b,c,substring(d for 30), length(d) from clstr_tst O... + ^ +-- Verify that inheritance link still works +INSERT INTO clstr_tst_inh VALUES (0, 100, 'in child table'); +ERROR: relation "clstr_tst_inh" does not exist +LINE 1: INSERT INTO clstr_tst_inh VALUES (0, 100, 'in child table'); + ^ +SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY a, b, c; +ERROR: relation "clstr_tst" does not exist +LINE 1: SELECT a,b,c,substring(d for 30), length(d) from clstr_tst O... + ^ +-- Verify that foreign key link still works +INSERT INTO clstr_tst (b, c) VALUES (1111, 'this should fail'); +ERROR: relation "clstr_tst" does not exist +LINE 1: INSERT INTO clstr_tst (b, c) VALUES (1111, 'this should fail... + ^ +SELECT conname FROM pg_constraint WHERE conrelid = 'clstr_tst'::regclass +ORDER BY 1; +ERROR: relation "clstr_tst" does not exist +LINE 1: ...ELECT conname FROM pg_constraint WHERE conrelid = 'clstr_tst... + ^ +SELECT relname, relkind, + EXISTS(SELECT 1 FROM pg_class WHERE oid = c.reltoastrelid) AS hastoast +FROM pg_class c WHERE relname LIKE 'clstr_tst%' ORDER BY relname; + relname | relkind | hastoast +---------+---------+---------- +(0 rows) + +-- Verify that indisclustered is correctly set +SELECT pg_class.relname FROM pg_index, pg_class, pg_class AS pg_class_2 +WHERE pg_class.oid=indexrelid + AND indrelid=pg_class_2.oid + AND pg_class_2.relname = 'clstr_tst' + AND indisclustered; + relname +--------- +(0 rows) + +-- Try changing indisclustered +ALTER TABLE clstr_tst CLUSTER ON clstr_tst_b_c; +ERROR: relation "clstr_tst" does not exist +SELECT pg_class.relname FROM pg_index, pg_class, pg_class AS pg_class_2 +WHERE pg_class.oid=indexrelid + AND indrelid=pg_class_2.oid + AND pg_class_2.relname = 'clstr_tst' + AND indisclustered; + relname +--------- +(0 rows) + +-- Try turning off all clustering +ALTER TABLE clstr_tst SET WITHOUT CLUSTER; +ERROR: relation "clstr_tst" does not exist +SELECT pg_class.relname FROM pg_index, pg_class, pg_class AS pg_class_2 +WHERE pg_class.oid=indexrelid + AND indrelid=pg_class_2.oid + AND pg_class_2.relname = 'clstr_tst' + AND indisclustered; + relname +--------- +(0 rows) + +-- Verify that clustering all tables does in fact cluster the right ones +CREATE USER clstr_user; +CREATE TABLE clstr_1 (a INT PRIMARY KEY); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "clstr_1_pkey" for table "clstr_1" +CREATE TABLE clstr_2 (a INT PRIMARY KEY); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "clstr_2_pkey" for table "clstr_2" +CREATE TABLE clstr_3 (a INT PRIMARY KEY); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "clstr_3_pkey" for table "clstr_3" +ALTER TABLE clstr_1 OWNER TO clstr_user; +ALTER TABLE clstr_3 OWNER TO clstr_user; +GRANT SELECT ON clstr_2 TO clstr_user; +INSERT INTO clstr_1 VALUES (2); +INSERT INTO clstr_1 VALUES (1); +INSERT INTO clstr_2 VALUES (2); +INSERT INTO clstr_2 VALUES (1); +INSERT INTO clstr_3 VALUES (2); +INSERT INTO clstr_3 VALUES (1); +-- "CLUSTER <tablename>" on a table that hasn't been clustered +CLUSTER clstr_2; +ERROR: there is no previously clustered index for table "clstr_2" +CLUSTER clstr_1_pkey ON clstr_1; +CLUSTER clstr_2 USING clstr_2_pkey; +SELECT * FROM clstr_1 UNION ALL + SELECT * FROM clstr_2 UNION ALL + SELECT * FROM clstr_3 + ORDER BY 1; + a +--- + 1 + 1 + 1 + 2 + 2 + 2 +(6 rows) + +-- revert to the original state +DELETE FROM clstr_1; +DELETE FROM clstr_2; +DELETE FROM clstr_3; +INSERT INTO clstr_1 VALUES (2); +INSERT INTO clstr_1 VALUES (1); +INSERT INTO clstr_2 VALUES (2); +INSERT INTO clstr_2 VALUES (1); +INSERT INTO clstr_3 VALUES (2); +INSERT INTO clstr_3 VALUES (1); +-- this user can only cluster clstr_1 and clstr_3, but the latter +-- has not been clustered +SET SESSION AUTHORIZATION clstr_user; +CLUSTER; +SELECT * FROM clstr_1 UNION ALL + SELECT * FROM clstr_2 UNION ALL + SELECT * FROM clstr_3 + ORDER BY 1; + a +--- + 1 + 1 + 1 + 2 + 2 + 2 +(6 rows) + +-- cluster a single table using the indisclustered bit previously set +DELETE FROM clstr_1; +INSERT INTO clstr_1 VALUES (2); +INSERT INTO clstr_1 VALUES (1); +CLUSTER clstr_1; +SELECT * FROM clstr_1 +ORDER BY 1; + a +--- + 1 + 2 +(2 rows) + +-- Test MVCC-safety of cluster. There isn't much we can do to verify the +-- results with a single backend... +CREATE TABLE clustertest (key int PRIMARY KEY); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "clustertest_pkey" for table "clustertest" +INSERT INTO clustertest VALUES (10); +INSERT INTO clustertest VALUES (20); +INSERT INTO clustertest VALUES (30); +INSERT INTO clustertest VALUES (40); +INSERT INTO clustertest VALUES (50); +-- Use a transaction so that updates are not committed when CLUSTER sees 'em +BEGIN; +-- Test update where the old row version is found first in the scan +UPDATE clustertest SET key = 100 WHERE key = 10; +ERROR: Partition column can't be updated in current version +-- Test update where the new row version is found first in the scan +UPDATE clustertest SET key = 35 WHERE key = 40; +ERROR: current transaction is aborted, commands ignored until end of transaction block +-- Test longer update chain +UPDATE clustertest SET key = 60 WHERE key = 50; +ERROR: current transaction is aborted, commands ignored until end of transaction block +UPDATE clustertest SET key = 70 WHERE key = 60; +ERROR: current transaction is aborted, commands ignored until end of transaction block +UPDATE clustertest SET key = 80 WHERE key = 70; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SELECT * FROM clustertest ORDER BY 1; +ERROR: current transaction is aborted, commands ignored until end of transaction block +CLUSTER clustertest_pkey ON clustertest; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SELECT * FROM clustertest ORDER BY 1; +ERROR: current transaction is aborted, commands ignored until end of transaction block +COMMIT; +SELECT * FROM clustertest ORDER BY 1; + key +----- + 10 + 20 + 30 + 40 + 50 +(5 rows) + +-- check that temp tables can be clustered +create temp table clstr_temp (col1 int primary key, col2 text); +ERROR: PG-XC does not yet support temporary tables +insert into clstr_temp values (2, 'two'), (1, 'one'); +ERROR: relation "clstr_temp" does not exist +LINE 1: insert into clstr_temp values (2, 'two'), (1, 'one'); + ^ +cluster clstr_temp using clstr_temp_pkey; +ERROR: relation "clstr_temp" does not exist +select * from clstr_temp ORDER BY 1; +ERROR: relation "clstr_temp" does not exist +LINE 1: select * from clstr_temp ORDER BY 1; + ^ +drop table clstr_temp; +ERROR: table "clstr_temp" does not exist +-- clean up +\c - +DROP TABLE clustertest; +DROP TABLE clstr_1; +DROP TABLE clstr_2; +DROP TABLE clstr_3; +DROP USER clstr_user; ----------------------------------------------------------------------- Summary of changes: src/test/regress/expected/cluster_1.out | 395 +++++++++++++++++++++++++++++++ 1 files changed, 395 insertions(+), 0 deletions(-) create mode 100644 src/test/regress/expected/cluster_1.out hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-23 10:35:04
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 6b7c2fee9839c195d5d19be2d1e8457b7125fbd7 (commit) from 0c8315711375436158ddf9cc5950582a864deb67 (commit) - Log ----------------------------------------------------------------- commit 6b7c2fee9839c195d5d19be2d1e8457b7125fbd7 Author: Michael P <mic...@us...> Date: Wed Mar 23 19:33:36 2011 +0900 Fix for regression test portals_p2 This test uses relation onek2 which cannot be created because it depends on multiple parents. So this output is correct. diff --git a/src/test/regress/expected/portals_p2_1.out b/src/test/regress/expected/portals_p2_1.out new file mode 100644 index 0000000..8df791c --- /dev/null +++ b/src/test/regress/expected/portals_p2_1.out @@ -0,0 +1,87 @@ +-- +-- PORTALS_P2 +-- +BEGIN; +DECLARE foo13 CURSOR FOR + SELECT * FROM onek WHERE unique1 = 50; +DECLARE foo14 CURSOR FOR + SELECT * FROM onek WHERE unique1 = 51; +DECLARE foo15 CURSOR FOR + SELECT * FROM onek WHERE unique1 = 52; +DECLARE foo16 CURSOR FOR + SELECT * FROM onek WHERE unique1 = 53; +DECLARE foo17 CURSOR FOR + SELECT * FROM onek WHERE unique1 = 54; +DECLARE foo18 CURSOR FOR + SELECT * FROM onek WHERE unique1 = 55; +DECLARE foo19 CURSOR FOR + SELECT * FROM onek WHERE unique1 = 56; +DECLARE foo20 CURSOR FOR + SELECT * FROM onek WHERE unique1 = 57; +DECLARE foo21 CURSOR FOR + SELECT * FROM onek WHERE unique1 = 58; +DECLARE foo22 CURSOR FOR + SELECT * FROM onek WHERE unique1 = 59; +DECLARE foo23 CURSOR FOR + SELECT * FROM onek WHERE unique1 = 60; +DECLARE foo24 CURSOR FOR + SELECT * FROM onek2 WHERE unique1 = 50; +ERROR: relation "onek2" does not exist +LINE 2: SELECT * FROM onek2 WHERE unique1 = 50; + ^ +DECLARE foo25 CURSOR FOR + SELECT * FROM onek2 WHERE unique1 = 60; +ERROR: current transaction is aborted, commands ignored until end of transaction block +FETCH all in foo13; +ERROR: current transaction is aborted, commands ignored until end of transaction block +FETCH all in foo14; +ERROR: current transaction is aborted, commands ignored until end of transaction block +FETCH all in foo15; +ERROR: current transaction is aborted, commands ignored until end of transaction block +FETCH all in foo16; +ERROR: current transaction is aborted, commands ignored until end of transaction block +FETCH all in foo17; +ERROR: current transaction is aborted, commands ignored until end of transaction block +FETCH all in foo18; +ERROR: current transaction is aborted, commands ignored until end of transaction block +FETCH all in foo19; +ERROR: current transaction is aborted, commands ignored until end of transaction block +FETCH all in foo20; +ERROR: current transaction is aborted, commands ignored until end of transaction block +FETCH all in foo21; +ERROR: current transaction is aborted, commands ignored until end of transaction block +FETCH all in foo22; +ERROR: current transaction is aborted, commands ignored until end of transaction block +FETCH all in foo23; +ERROR: current transaction is aborted, commands ignored until end of transaction block +FETCH all in foo24; +ERROR: current transaction is aborted, commands ignored until end of transaction block +FETCH all in foo25; +ERROR: current transaction is aborted, commands ignored until end of transaction block +CLOSE foo13; +ERROR: current transaction is aborted, commands ignored until end of transaction block +CLOSE foo14; +ERROR: current transaction is aborted, commands ignored until end of transaction block +CLOSE foo15; +ERROR: current transaction is aborted, commands ignored until end of transaction block +CLOSE foo16; +ERROR: current transaction is aborted, commands ignored until end of transaction block +CLOSE foo17; +ERROR: current transaction is aborted, commands ignored until end of transaction block +CLOSE foo18; +ERROR: current transaction is aborted, commands ignored until end of transaction block +CLOSE foo19; +ERROR: current transaction is aborted, commands ignored until end of transaction block +CLOSE foo20; +ERROR: current transaction is aborted, commands ignored until end of transaction block +CLOSE foo21; +ERROR: current transaction is aborted, commands ignored until end of transaction block +CLOSE foo22; +ERROR: current transaction is aborted, commands ignored until end of transaction block +CLOSE foo23; +ERROR: current transaction is aborted, commands ignored until end of transaction block +CLOSE foo24; +ERROR: current transaction is aborted, commands ignored until end of transaction block +CLOSE foo25; +ERROR: current transaction is aborted, commands ignored until end of transaction block +END; ----------------------------------------------------------------------- Summary of changes: src/test/regress/expected/portals_p2_1.out | 87 ++++++++++++++++++++++++++++ 1 files changed, 87 insertions(+), 0 deletions(-) create mode 100644 src/test/regress/expected/portals_p2_1.out hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-23 09:54:18
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 0c8315711375436158ddf9cc5950582a864deb67 (commit) from 80576863fad916d25cb4b0c4af42d0ebcaac990a (commit) - Log ----------------------------------------------------------------- commit 0c8315711375436158ddf9cc5950582a864deb67 Author: Michael P <mic...@us...> Date: Wed Mar 23 18:53:29 2011 +0900 Fix for regression test namespace Postgres-XC does not support yet INTO clause, so this output is correct. diff --git a/src/test/regress/expected/namespace_1.out b/src/test/regress/expected/namespace_1.out new file mode 100644 index 0000000..2452be2 --- /dev/null +++ b/src/test/regress/expected/namespace_1.out @@ -0,0 +1,51 @@ +-- +-- Regression tests for schemas (namespaces) +-- +CREATE SCHEMA test_schema_1 + CREATE UNIQUE INDEX abc_a_idx ON abc (a) + CREATE VIEW abc_view AS + SELECT a+1 AS a, b+1 AS b FROM abc + CREATE TABLE abc ( + a serial, + b int UNIQUE + ); +ERROR: Postgres-XC does not support SERIAL yet +DETAIL: The feature is not currently supported +-- verify that the objects were created +SELECT COUNT(*) FROM pg_class WHERE relnamespace = + (SELECT oid FROM pg_namespace WHERE nspname = 'test_schema_1'); + count +------- + 0 +(1 row) + +INSERT INTO test_schema_1.abc DEFAULT VALUES; +ERROR: schema "test_schema_1" does not exist +LINE 1: INSERT INTO test_schema_1.abc DEFAULT VALUES; + ^ +INSERT INTO test_schema_1.abc DEFAULT VALUES; +ERROR: schema "test_schema_1" does not exist +LINE 1: INSERT INTO test_schema_1.abc DEFAULT VALUES; + ^ +INSERT INTO test_schema_1.abc DEFAULT VALUES; +ERROR: schema "test_schema_1" does not exist +LINE 1: INSERT INTO test_schema_1.abc DEFAULT VALUES; + ^ +SELECT * FROM test_schema_1.abc ORDER BY a; +ERROR: schema "test_schema_1" does not exist +LINE 1: SELECT * FROM test_schema_1.abc ORDER BY a; + ^ +SELECT * FROM test_schema_1.abc_view ORDER BY a; +ERROR: schema "test_schema_1" does not exist +LINE 1: SELECT * FROM test_schema_1.abc_view ORDER BY a; + ^ +DROP SCHEMA test_schema_1 CASCADE; +ERROR: schema "test_schema_1" does not exist +-- verify that the objects were dropped +SELECT COUNT(*) FROM pg_class WHERE relnamespace = + (SELECT oid FROM pg_namespace WHERE nspname = 'test_schema_1'); + count +------- + 0 +(1 row) + ----------------------------------------------------------------------- Summary of changes: .../expected/{namespace.out => namespace_1.out} | 39 ++++++++++---------- 1 files changed, 19 insertions(+), 20 deletions(-) copy src/test/regress/expected/{namespace.out => namespace_1.out} (55%) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-23 09:51:55
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 80576863fad916d25cb4b0c4af42d0ebcaac990a (commit) via edaff5cb25e0aa8c21b5406133c2cbea53ef7b0c (commit) from 4b03e05fb307a45134a3113c5364bafcf7d29bc6 (commit) - Log ----------------------------------------------------------------- commit 80576863fad916d25cb4b0c4af42d0ebcaac990a Author: Michael P <mic...@us...> Date: Wed Mar 23 18:50:48 2011 +0900 Fix for regression test hash_index Partition column of a distributed table cannot be updated, so this output is correct. diff --git a/src/test/regress/expected/hash_index_1.out b/src/test/regress/expected/hash_index_1.out new file mode 100644 index 0000000..97e5933 --- /dev/null +++ b/src/test/regress/expected/hash_index_1.out @@ -0,0 +1,202 @@ +-- +-- HASH_INDEX +-- grep 843938989 hash.data +-- +SELECT * FROM hash_i4_heap + WHERE hash_i4_heap.random = 843938989; + seqno | random +-------+----------- + 15 | 843938989 +(1 row) + +-- +-- hash index +-- grep 66766766 hash.data +-- +SELECT * FROM hash_i4_heap + WHERE hash_i4_heap.random = 66766766; + seqno | random +-------+-------- +(0 rows) + +-- +-- hash index +-- grep 1505703298 hash.data +-- +SELECT * FROM hash_name_heap + WHERE hash_name_heap.random = '1505703298'::name; + seqno | random +-------+------------ + 9838 | 1505703298 +(1 row) + +-- +-- hash index +-- grep 7777777 hash.data +-- +SELECT * FROM hash_name_heap + WHERE hash_name_heap.random = '7777777'::name; + seqno | random +-------+-------- +(0 rows) + +-- +-- hash index +-- grep 1351610853 hash.data +-- +SELECT * FROM hash_txt_heap + WHERE hash_txt_heap.random = '1351610853'::text; + seqno | random +-------+------------ + 5677 | 1351610853 +(1 row) + +-- +-- hash index +-- grep 111111112222222233333333 hash.data +-- +SELECT * FROM hash_txt_heap + WHERE hash_txt_heap.random = '111111112222222233333333'::text; + seqno | random +-------+-------- +(0 rows) + +-- +-- hash index +-- grep 444705537 hash.data +-- +SELECT * FROM hash_f8_heap + WHERE hash_f8_heap.random = '444705537'::float8; + seqno | random +-------+----------- + 7853 | 444705537 +(1 row) + +-- +-- hash index +-- grep 88888888 hash.data +-- +SELECT * FROM hash_f8_heap + WHERE hash_f8_heap.random = '88888888'::float8; + seqno | random +-------+-------- +(0 rows) + +-- +-- hash index +-- grep '^90[^0-9]' hashovfl.data +-- +-- SELECT count(*) AS i988 FROM hash_ovfl_heap +-- WHERE x = 90; +-- +-- hash index +-- grep '^1000[^0-9]' hashovfl.data +-- +-- SELECT count(*) AS i0 FROM hash_ovfl_heap +-- WHERE x = 1000; +-- +-- HASH +-- +UPDATE hash_i4_heap + SET random = 1 + WHERE hash_i4_heap.seqno = 1492; +SELECT h.seqno AS i1492, h.random AS i1 + FROM hash_i4_heap h + WHERE h.random = 1; + i1492 | i1 +-------+---- + 1492 | 1 +(1 row) + +UPDATE hash_i4_heap + SET seqno = 20000 + WHERE hash_i4_heap.random = 1492795354; +ERROR: Partition column can't be updated in current version +SELECT h.seqno AS i20000 + FROM hash_i4_heap h + WHERE h.random = 1492795354; + i20000 +-------- + 6866 +(1 row) + +UPDATE hash_name_heap + SET random = '0123456789abcdef'::name + WHERE hash_name_heap.seqno = 6543; +SELECT h.seqno AS i6543, h.random AS c0_to_f + FROM hash_name_heap h + WHERE h.random = '0123456789abcdef'::name; + i6543 | c0_to_f +-------+------------------ + 6543 | 0123456789abcdef +(1 row) + +UPDATE hash_name_heap + SET seqno = 20000 + WHERE hash_name_heap.random = '76652222'::name; +ERROR: Partition column can't be updated in current version +-- +-- this is the row we just replaced; index scan should return zero rows +-- +SELECT h.seqno AS emptyset + FROM hash_name_heap h + WHERE h.random = '76652222'::name; + emptyset +---------- +(0 rows) + +UPDATE hash_txt_heap + SET random = '0123456789abcdefghijklmnop'::text + WHERE hash_txt_heap.seqno = 4002; +SELECT h.seqno AS i4002, h.random AS c0_to_p + FROM hash_txt_heap h + WHERE h.random = '0123456789abcdefghijklmnop'::text; + i4002 | c0_to_p +-------+---------------------------- + 4002 | 0123456789abcdefghijklmnop +(1 row) + +UPDATE hash_txt_heap + SET seqno = 20000 + WHERE hash_txt_heap.random = '959363399'::text; +ERROR: Partition column can't be updated in current version +SELECT h.seqno AS t20000 + FROM hash_txt_heap h + WHERE h.random = '959363399'::text; + t20000 +-------- + 5489 +(1 row) + +UPDATE hash_f8_heap + SET random = '-1234.1234'::float8 + WHERE hash_f8_heap.seqno = 8906; +SELECT h.seqno AS i8096, h.random AS f1234_1234 + FROM hash_f8_heap h + WHERE h.random = '-1234.1234'::float8; + i8096 | f1234_1234 +-------+------------ + 8906 | -1234.1234 +(1 row) + +UPDATE hash_f8_heap + SET seqno = 20000 + WHERE hash_f8_heap.random = '488912369'::float8; +ERROR: Partition column can't be updated in current version +SELECT h.seqno AS f20000 + FROM hash_f8_heap h + WHERE h.random = '488912369'::float8; + f20000 +-------- + 8932 +(1 row) + +-- UPDATE hash_ovfl_heap +-- SET x = 1000 +-- WHERE x = 90; +-- this vacuums the index as well +-- VACUUM hash_ovfl_heap; +-- SELECT count(*) AS i0 FROM hash_ovfl_heap +-- WHERE x = 90; +-- SELECT count(*) AS i988 FROM hash_ovfl_heap +-- WHERE x = 1000; commit edaff5cb25e0aa8c21b5406133c2cbea53ef7b0c Author: Michael P <mic...@us...> Date: Wed Mar 23 18:47:14 2011 +0900 Fix for regression test random INTO clause is not yet supported, so this output is correct. diff --git a/src/test/regress/expected/random_1.out b/src/test/regress/expected/random_1.out new file mode 100644 index 0000000..871bd36 --- /dev/null +++ b/src/test/regress/expected/random_1.out @@ -0,0 +1,60 @@ +-- +-- RANDOM +-- Test the random function +-- +-- count the number of tuples originally, should be 1000 +SELECT count(*) FROM onek; + count +------- + 1000 +(1 row) + +-- pick three random rows, they shouldn't match +(SELECT unique1 AS random + FROM onek ORDER BY random() LIMIT 1) +INTERSECT +(SELECT unique1 AS random + FROM onek ORDER BY random() LIMIT 1) +INTERSECT +(SELECT unique1 AS random + FROM onek ORDER BY random() LIMIT 1); + random +-------- +(0 rows) + +-- count roughly 1/10 of the tuples +SELECT count(*) AS random INTO RANDOM_TBL + FROM onek WHERE random() < 1.0/10; +ERROR: INTO clause not yet supported +-- select again, the count should be different +INSERT INTO RANDOM_TBL (random) + SELECT count(*) + FROM onek WHERE random() < 1.0/10; +ERROR: relation "random_tbl" does not exist +LINE 1: INSERT INTO RANDOM_TBL (random) + ^ +-- select again, the count should be different +INSERT INTO RANDOM_TBL (random) + SELECT count(*) + FROM onek WHERE random() < 1.0/10; +ERROR: relation "random_tbl" does not exist +LINE 1: INSERT INTO RANDOM_TBL (random) + ^ +-- select again, the count should be different +INSERT INTO RANDOM_TBL (random) + SELECT count(*) + FROM onek WHERE random() < 1.0/10; +ERROR: relation "random_tbl" does not exist +LINE 1: INSERT INTO RANDOM_TBL (random) + ^ +-- now test that they are different counts +SELECT random, count(random) FROM RANDOM_TBL + GROUP BY random HAVING count(random) > 3; +ERROR: relation "random_tbl" does not exist +LINE 1: SELECT random, count(random) FROM RANDOM_TBL + ^ +SELECT AVG(random) FROM RANDOM_TBL + HAVING AVG(random) NOT BETWEEN 80 AND 120; +ERROR: relation "random_tbl" does not exist +LINE 1: SELECT AVG(random) FROM RANDOM_TBL + ^ ----------------------------------------------------------------------- Summary of changes: .../expected/{hash_index.out => hash_index_1.out} | 10 +++++-- .../regress/expected/{random.out => random_1.out} | 24 +++++++++++++------ 2 files changed, 23 insertions(+), 11 deletions(-) copy src/test/regress/expected/{hash_index.out => hash_index_1.out} (93%) copy src/test/regress/expected/{random.out => random_1.out} (65%) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-23 09:45:26
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 4b03e05fb307a45134a3113c5364bafcf7d29bc6 (commit) from 29637b7f7d32ea593f9d2689ec44a0c12511a274 (commit) - Log ----------------------------------------------------------------- commit 4b03e05fb307a45134a3113c5364bafcf7d29bc6 Author: Michael P <mic...@us...> Date: Wed Mar 23 18:44:23 2011 +0900 Fix for regression test transactions SAVEPOINT, PREPARE and EXECUTE are not supported in Postgres-XC, so this output is correct. diff --git a/src/test/regress/expected/transactions_1.out b/src/test/regress/expected/transactions_1.out new file mode 100644 index 0000000..967bd3c --- /dev/null +++ b/src/test/regress/expected/transactions_1.out @@ -0,0 +1,561 @@ +-- +-- TRANSACTIONS +-- +BEGIN; +SELECT * + INTO TABLE xacttest + FROM aggtest; +ERROR: INTO clause not yet supported +INSERT INTO xacttest (a, b) VALUES (777, 777.777); +ERROR: current transaction is aborted, commands ignored until end of transaction block +END; +-- should retrieve one value-- +SELECT a FROM xacttest WHERE a > 100; +ERROR: relation "xacttest" does not exist +LINE 1: SELECT a FROM xacttest WHERE a > 100; + ^ +BEGIN; +CREATE TABLE disappear (a int4); +DELETE FROM aggtest; +-- should be empty +SELECT * FROM aggtest; + a | b +---+--- +(0 rows) + +ABORT; +-- should not exist +SELECT oid FROM pg_class WHERE relname = 'disappear'; + oid +----- +(0 rows) + +-- should have members again +SELECT * FROM aggtest order by a, b; + a | b +-----+--------- + 0 | 0.09561 + 42 | 324.78 + 56 | 7.8 + 100 | 99.097 +(4 rows) + +-- Read-only tests +CREATE TABLE writetest (a int); +CREATE TEMPORARY TABLE temptest (a int); +ERROR: PG-XC does not yet support temporary tables +SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY; +DROP TABLE writetest; -- fail +ERROR: cannot execute DROP TABLE in a read-only transaction +INSERT INTO writetest VALUES (1); -- fail +ERROR: cannot execute INSERT in a read-only transaction +SELECT * FROM writetest; -- ok + a +--- +(0 rows) + +DELETE FROM temptest; -- ok +ERROR: relation "temptest" does not exist +LINE 1: DELETE FROM temptest; + ^ +UPDATE temptest SET a = 0 FROM writetest WHERE temptest.a = 1 AND writetest.a = temptest.a; -- ok +ERROR: relation "temptest" does not exist +LINE 1: UPDATE temptest SET a = 0 FROM writetest WHERE temptest.a = ... + ^ +PREPARE test AS UPDATE writetest SET a = 0; -- ok +ERROR: Postgres-XC does not support PREPARE yet +DETAIL: The feature is not currently supported +EXECUTE test; -- fail +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +SELECT * FROM writetest, temptest; -- ok +ERROR: relation "temptest" does not exist +LINE 1: SELECT * FROM writetest, temptest; + ^ +CREATE TABLE test AS SELECT * FROM writetest; -- fail +ERROR: INTO clause not yet supported +START TRANSACTION READ WRITE; +DROP TABLE writetest; -- ok +COMMIT; +-- Subtransactions, basic tests +-- create & drop tables +SET SESSION CHARACTERISTICS AS TRANSACTION READ WRITE; +CREATE TABLE foobar (a int); +BEGIN; + CREATE TABLE foo (a int); + SAVEPOINT one; +ERROR: SAVEPOINT is not yet supported. + DROP TABLE foo; +ERROR: current transaction is aborted, commands ignored until end of transaction block + CREATE TABLE bar (a int); +ERROR: current transaction is aborted, commands ignored until end of transaction block + ROLLBACK TO SAVEPOINT one; +ERROR: no such savepoint + RELEASE SAVEPOINT one; +ERROR: current transaction is aborted, commands ignored until end of transaction block + SAVEPOINT two; +ERROR: current transaction is aborted, commands ignored until end of transaction block + CREATE TABLE baz (a int); +ERROR: current transaction is aborted, commands ignored until end of transaction block + RELEASE SAVEPOINT two; +ERROR: current transaction is aborted, commands ignored until end of transaction block + drop TABLE foobar; +ERROR: current transaction is aborted, commands ignored until end of transaction block + CREATE TABLE barbaz (a int); +ERROR: current transaction is aborted, commands ignored until end of transaction block +COMMIT; +-- should exist: barbaz, baz, foo +SELECT * FROM foo; -- should be empty +ERROR: relation "foo" does not exist +LINE 1: SELECT * FROM foo; + ^ +SELECT * FROM bar; -- shouldn't exist +ERROR: relation "bar" does not exist +LINE 1: SELECT * FROM bar; + ^ +SELECT * FROM barbaz; -- should be empty +ERROR: relation "barbaz" does not exist +LINE 1: SELECT * FROM barbaz; + ^ +SELECT * FROM baz; -- should be empty +ERROR: relation "baz" does not exist +LINE 1: SELECT * FROM baz; + ^ +-- inserts +BEGIN; + INSERT INTO foo VALUES (1); +ERROR: relation "foo" does not exist +LINE 1: INSERT INTO foo VALUES (1); + ^ + SAVEPOINT one; +ERROR: current transaction is aborted, commands ignored until end of transaction block + INSERT into bar VALUES (1); +ERROR: current transaction is aborted, commands ignored until end of transaction block + ROLLBACK TO one; +ERROR: no such savepoint + RELEASE SAVEPOINT one; +ERROR: current transaction is aborted, commands ignored until end of transaction block + SAVEPOINT two; +ERROR: current transaction is aborted, commands ignored until end of transaction block + INSERT into barbaz VALUES (1); +ERROR: current transaction is aborted, commands ignored until end of transaction block + RELEASE two; +ERROR: current transaction is aborted, commands ignored until end of transaction block + SAVEPOINT three; +ERROR: current transaction is aborted, commands ignored until end of transaction block + SAVEPOINT four; +ERROR: current transaction is aborted, commands ignored until end of transaction block + INSERT INTO foo VALUES (2); +ERROR: current transaction is aborted, commands ignored until end of transaction block + RELEASE SAVEPOINT four; +ERROR: current transaction is aborted, commands ignored until end of transaction block + ROLLBACK TO SAVEPOINT three; +ERROR: no such savepoint + RELEASE SAVEPOINT three; +ERROR: current transaction is aborted, commands ignored until end of transaction block + INSERT INTO foo VALUES (3); +ERROR: current transaction is aborted, commands ignored until end of transaction block +COMMIT; +SELECT * FROM foo ORDER BY a; -- should have 1 and 3 +ERROR: relation "foo" does not exist +LINE 1: SELECT * FROM foo ORDER BY a; + ^ +SELECT * FROM barbaz ORDER BY a; -- should have 1 +ERROR: relation "barbaz" does not exist +LINE 1: SELECT * FROM barbaz ORDER BY a; + ^ +-- test whole-tree commit +BEGIN; + SAVEPOINT one; +ERROR: SAVEPOINT is not yet supported. + SELECT foo; +ERROR: current transaction is aborted, commands ignored until end of transaction block + ROLLBACK TO SAVEPOINT one; +ERROR: no such savepoint + RELEASE SAVEPOINT one; +ERROR: current transaction is aborted, commands ignored until end of transaction block + SAVEPOINT two; +ERROR: current transaction is aborted, commands ignored until end of transaction block + CREATE TABLE savepoints (a int); +ERROR: current transaction is aborted, commands ignored until end of transaction block + SAVEPOINT three; +ERROR: current transaction is aborted, commands ignored until end of transaction block + INSERT INTO savepoints VALUES (1); +ERROR: current transaction is aborted, commands ignored until end of transaction block + SAVEPOINT four; +ERROR: current transaction is aborted, commands ignored until end of transaction block + INSERT INTO savepoints VALUES (2); +ERROR: current transaction is aborted, commands ignored until end of transaction block + SAVEPOINT five; +ERROR: current transaction is aborted, commands ignored until end of transaction block + INSERT INTO savepoints VALUES (3); +ERROR: current transaction is aborted, commands ignored until end of transaction block + ROLLBACK TO SAVEPOINT five; +ERROR: no such savepoint +COMMIT; +COMMIT; -- should not be in a transaction block +WARNING: there is no transaction in progress +SELECT * FROM savepoints ORDER BY 1; +ERROR: relation "savepoints" does not exist +LINE 1: SELECT * FROM savepoints ORDER BY 1; + ^ +-- test whole-tree rollback +BEGIN; + SAVEPOINT one; +ERROR: SAVEPOINT is not yet supported. + DELETE FROM savepoints WHERE a=1; +ERROR: current transaction is aborted, commands ignored until end of transaction block + RELEASE SAVEPOINT one; +ERROR: current transaction is aborted, commands ignored until end of transaction block + SAVEPOINT two; +ERROR: current transaction is aborted, commands ignored until end of transaction block + DELETE FROM savepoints WHERE a=1; +ERROR: current transaction is aborted, commands ignored until end of transaction block + SAVEPOINT three; +ERROR: current transaction is aborted, commands ignored until end of transaction block + DELETE FROM savepoints WHERE a=2; +ERROR: current transaction is aborted, commands ignored until end of transaction block +ROLLBACK; +COMMIT; -- should not be in a transaction block +WARNING: there is no transaction in progress + +SELECT * FROM savepoints ORDER BY 1; +ERROR: relation "savepoints" does not exist +LINE 1: SELECT * FROM savepoints ORDER BY 1; + ^ +-- test whole-tree commit on an aborted subtransaction +BEGIN; + INSERT INTO savepoints VALUES (4); +ERROR: relation "savepoints" does not exist +LINE 1: INSERT INTO savepoints VALUES (4); + ^ + SAVEPOINT one; +ERROR: current transaction is aborted, commands ignored until end of transaction block + INSERT INTO savepoints VALUES (5); +ERROR: current transaction is aborted, commands ignored until end of transaction block + SELECT foo; +ERROR: current transaction is aborted, commands ignored until end of transaction block +COMMIT; +SELECT * FROM savepoints ORDER BY a; +ERROR: relation "savepoints" does not exist +LINE 1: SELECT * FROM savepoints ORDER BY a; + ^ +BEGIN; + INSERT INTO savepoints VALUES (6); +ERROR: relation "savepoints" does not exist +LINE 1: INSERT INTO savepoints VALUES (6); + ^ + SAVEPOINT one; +ERROR: current transaction is aborted, commands ignored until end of transaction block + INSERT INTO savepoints VALUES (7); +ERROR: current transaction is aborted, commands ignored until end of transaction block + RELEASE SAVEPOINT one; +ERROR: current transaction is aborted, commands ignored until end of transaction block + INSERT INTO savepoints VALUES (8); +ERROR: current transaction is aborted, commands ignored until end of transaction block +COMMIT; +-- rows 6 and 8 should have been created by the same xact +SELECT a.xmin = b.xmin FROM savepoints a, savepoints b WHERE a.a=6 AND b.a=8; +ERROR: relation "savepoints" does not exist +LINE 1: SELECT a.xmin = b.xmin FROM savepoints a, savepoints b WHERE... + ^ +-- rows 6 and 7 should have been created by different xacts +SELECT a.xmin = b.xmin FROM savepoints a, savepoints b WHERE a.a=6 AND b.a=7; +ERROR: relation "savepoints" does not exist +LINE 1: SELECT a.xmin = b.xmin FROM savepoints a, savepoints b WHERE... + ^ +BEGIN; + INSERT INTO savepoints VALUES (9); +ERROR: relation "savepoints" does not exist +LINE 1: INSERT INTO savepoints VALUES (9); + ^ + SAVEPOINT one; +ERROR: current transaction is aborted, commands ignored until end of transaction block + INSERT INTO savepoints VALUES (10); +ERROR: current transaction is aborted, commands ignored until end of transaction block + ROLLBACK TO SAVEPOINT one; +ERROR: no such savepoint + INSERT INTO savepoints VALUES (11); +ERROR: current transaction is aborted, commands ignored until end of transaction block +COMMIT; +SELECT a FROM savepoints WHERE a in (9, 10, 11) ORDER BY a; +ERROR: relation "savepoints" does not exist +LINE 1: SELECT a FROM savepoints WHERE a in (9, 10, 11) ORDER BY a; + ^ +-- rows 9 and 11 should have been created by different xacts +SELECT a.xmin = b.xmin FROM savepoints a, savepoints b WHERE a.a=9 AND b.a=11; +ERROR: relation "savepoints" does not exist +LINE 1: SELECT a.xmin = b.xmin FROM savepoints a, savepoints b WHERE... + ^ +BEGIN; + INSERT INTO savepoints VALUES (12); +ERROR: relation "savepoints" does not exist +LINE 1: INSERT INTO savepoints VALUES (12); + ^ + SAVEPOINT one; +ERROR: current transaction is aborted, commands ignored until end of transaction block + INSERT INTO savepoints VALUES (13); +ERROR: current transaction is aborted, commands ignored until end of transaction block + SAVEPOINT two; +ERROR: current transaction is aborted, commands ignored until end of transaction block + INSERT INTO savepoints VALUES (14); +ERROR: current transaction is aborted, commands ignored until end of transaction block + ROLLBACK TO SAVEPOINT one; +ERROR: no such savepoint + INSERT INTO savepoints VALUES (15); +ERROR: current transaction is aborted, commands ignored until end of transaction block + SAVEPOINT two; +ERROR: current transaction is aborted, commands ignored until end of transaction block + INSERT INTO savepoints VALUES (16); +ERROR: current transaction is aborted, commands ignored until end of transaction block + SAVEPOINT three; +ERROR: current transaction is aborted, commands ignored until end of transaction block + INSERT INTO savepoints VALUES (17); +ERROR: current transaction is aborted, commands ignored until end of transaction block +COMMIT; +SELECT a FROM savepoints WHERE a BETWEEN 12 AND 17 ORDER BY a; +ERROR: relation "savepoints" does not exist +LINE 1: SELECT a FROM savepoints WHERE a BETWEEN 12 AND 17 ORDER BY ... + ^ +BEGIN; + INSERT INTO savepoints VALUES (18); +ERROR: relation "savepoints" does not exist +LINE 1: INSERT INTO savepoints VALUES (18); + ^ + SAVEPOINT one; +ERROR: current transaction is aborted, commands ignored until end of transaction block + INSERT INTO savepoints VALUES (19); +ERROR: current transaction is aborted, commands ignored until end of transaction block + SAVEPOINT two; +ERROR: current transaction is aborted, commands ignored until end of transaction block + INSERT INTO savepoints VALUES (20); +ERROR: current transaction is aborted, commands ignored until end of transaction block + ROLLBACK TO SAVEPOINT one; +ERROR: no such savepoint + INSERT INTO savepoints VALUES (21); +ERROR: current transaction is aborted, commands ignored until end of transaction block + ROLLBACK TO SAVEPOINT one; +ERROR: no such savepoint + INSERT INTO savepoints VALUES (22); +ERROR: current transaction is aborted, commands ignored until end of transaction block +COMMIT; +SELECT a FROM savepoints WHERE a BETWEEN 18 AND 22 ORDER BY a; +ERROR: relation "savepoints" does not exist +LINE 1: SELECT a FROM savepoints WHERE a BETWEEN 18 AND 22 ORDER BY ... + ^ +DROP TABLE savepoints; +ERROR: table "savepoints" does not exist +-- only in a transaction block: +SAVEPOINT one; +ERROR: SAVEPOINT is not yet supported. +ROLLBACK TO SAVEPOINT one; +ERROR: ROLLBACK TO SAVEPOINT can only be used in transaction blocks +RELEASE SAVEPOINT one; +ERROR: RELEASE SAVEPOINT can only be used in transaction blocks +-- Only "rollback to" allowed in aborted state +BEGIN; + SAVEPOINT one; +ERROR: SAVEPOINT is not yet supported. + SELECT 0/0; +ERROR: current transaction is aborted, commands ignored until end of transaction block + SAVEPOINT two; -- ignored till the end of ... +ERROR: current transaction is aborted, commands ignored until end of transaction block + RELEASE SAVEPOINT one; -- ignored till the end of ... +ERROR: current transaction is aborted, commands ignored until end of transaction block + ROLLBACK TO SAVEPOINT one; +ERROR: no such savepoint + SELECT 1; +ERROR: current transaction is aborted, commands ignored until end of transaction block +COMMIT; +SELECT 1; -- this should work + ?column? +---------- + 1 +(1 row) + +-- check non-transactional behavior of cursors +BEGIN; + DECLARE c CURSOR FOR SELECT unique2 FROM tenk1 ORDER BY unique2; + SAVEPOINT one; +ERROR: SAVEPOINT is not yet supported. + FETCH 10 FROM c; +ERROR: current transaction is aborted, commands ignored until end of transaction block + ROLLBACK TO SAVEPOINT one; +ERROR: no such savepoint + FETCH 10 FROM c; +ERROR: current transaction is aborted, commands ignored until end of transaction block + RELEASE SAVEPOINT one; +ERROR: current transaction is aborted, commands ignored until end of transaction block + FETCH 10 FROM c; +ERROR: current transaction is aborted, commands ignored until end of transaction block + CLOSE c; +ERROR: current transaction is aborted, commands ignored until end of transaction block + DECLARE c CURSOR FOR SELECT unique2/0 FROM tenk1 ORDER BY unique2; +ERROR: current transaction is aborted, commands ignored until end of transaction block + SAVEPOINT two; +ERROR: current transaction is aborted, commands ignored until end of transaction block + FETCH 10 FROM c; +ERROR: current transaction is aborted, commands ignored until end of transaction block + ROLLBACK TO SAVEPOINT two; +ERROR: no such savepoint + -- c is now dead to the world ... + FETCH 10 FROM c; +ERROR: current transaction is aborted, commands ignored until end of transaction block + ROLLBACK TO SAVEPOINT two; +ERROR: no such savepoint + RELEASE SAVEPOINT two; +ERROR: current transaction is aborted, commands ignored until end of transaction block + FETCH 10 FROM c; +ERROR: current transaction is aborted, commands ignored until end of transaction block +COMMIT; +-- +-- Check that "stable" functions are really stable. They should not be +-- able to see the partial results of the calling query. (Ideally we would +-- also check that they don't see commits of concurrent transactions, but +-- that's a mite hard to do within the limitations of pg_regress.) +-- +select * from xacttest order by a, b; +ERROR: relation "xacttest" does not exist +LINE 1: select * from xacttest order by a, b; + ^ +create or replace function max_xacttest() returns smallint language sql as +'select max(a) from xacttest' stable; +ERROR: relation "xacttest" does not exist +LINE 2: 'select max(a) from xacttest' stable; + ^ +begin; +update xacttest set a = max_xacttest() + 10 where a > 0; +ERROR: relation "xacttest" does not exist +LINE 1: update xacttest set a = max_xacttest() + 10 where a > 0; + ^ +select * from xacttest order by a, b; +ERROR: current transaction is aborted, commands ignored until end of transaction block +rollback; +-- But a volatile function can see the partial results of the calling query +create or replace function max_xacttest() returns smallint language sql as +'select max(a) from xacttest' volatile; +ERROR: relation "xacttest" does not exist +LINE 2: 'select max(a) from xacttest' volatile; + ^ +begin; +update xacttest set a = max_xacttest() + 10 where a > 0; +ERROR: relation "xacttest" does not exist +LINE 1: update xacttest set a = max_xacttest() + 10 where a > 0; + ^ +select * from xacttest order by a, b; +ERROR: current transaction is aborted, commands ignored until end of transaction block +rollback; +-- Now the same test with plpgsql (since it depends on SPI which is different) +create or replace function max_xacttest() returns smallint language plpgsql as +'begin return max(a) from xacttest; end' stable; +begin; +update xacttest set a = max_xacttest() + 10 where a > 0; +ERROR: relation "xacttest" does not exist +LINE 1: update xacttest set a = max_xacttest() + 10 where a > 0; + ^ +select * from xacttest order by a, b; +ERROR: current transaction is aborted, commands ignored until end of transaction block +rollback; +create or replace function max_xacttest() returns smallint language plpgsql as +'begin return max(a) from xacttest; end' volatile; +begin; +update xacttest set a = max_xacttest() + 10 where a > 0; +ERROR: relation "xacttest" does not exist +LINE 1: update xacttest set a = max_xacttest() + 10 where a > 0; + ^ +select * from xacttest order by a, b; +ERROR: current transaction is aborted, commands ignored until end of transaction block +rollback; +-- test case for problems with dropping an open relation during abort +BEGIN; + savepoint x; +ERROR: SAVEPOINT is not yet supported. + CREATE TABLE koju (a INT UNIQUE); +ERROR: current transaction is aborted, commands ignored until end of transaction block + INSERT INTO koju VALUES (1); +ERROR: current transaction is aborted, commands ignored until end of transaction block + INSERT INTO koju VALUES (1); +ERROR: current transaction is aborted, commands ignored until end of transaction block + rollback to x; +ERROR: no such savepoint + CREATE TABLE koju (a INT UNIQUE); +ERROR: current transaction is aborted, commands ignored until end of transaction block + INSERT INTO koju VALUES (1); +ERROR: current transaction is aborted, commands ignored until end of transaction block + INSERT INTO koju VALUES (1); +ERROR: current transaction is aborted, commands ignored until end of transaction block +ROLLBACK; +DROP TABLE foo; +ERROR: table "foo" does not exist +DROP TABLE baz; +ERROR: table "baz" does not exist +DROP TABLE barbaz; +ERROR: table "barbaz" does not exist +-- verify that cursors created during an aborted subtransaction are +-- closed, but that we do not rollback the effect of any FETCHs +-- performed in the aborted subtransaction +begin; +savepoint x; +ERROR: SAVEPOINT is not yet supported. +create table abc (a int); +ERROR: current transaction is aborted, commands ignored until end of transaction block +insert into abc values (5); +ERROR: current transaction is aborted, commands ignored until end of transaction block +insert into abc values (10); +ERROR: current transaction is aborted, commands ignored until end of transaction block +declare foo cursor for select * from abc; +ERROR: current transaction is aborted, commands ignored until end of transaction block +fetch from foo; +ERROR: current transaction is aborted, commands ignored until end of transaction block +rollback to x; +ERROR: no such savepoint +-- should fail +fetch from foo; +ERROR: current transaction is aborted, commands ignored until end of transaction block +commit; +begin; +create table abc (a int); +insert into abc values (5); +insert into abc values (10); +insert into abc values (15); +declare foo cursor for select * from abc; +fetch from foo; + a +---- + 10 +(1 row) + +savepoint x; +ERROR: SAVEPOINT is not yet supported. +fetch from foo; +ERROR: current transaction is aborted, commands ignored until end of transaction block +rollback to x; +ERROR: no such savepoint +fetch from foo; +ERROR: current transaction is aborted, commands ignored until end of transaction block +abort; +-- tests for the "tid" type +SELECT '(3, 3)'::tid = '(3, 4)'::tid; + ?column? +---------- + f +(1 row) + +SELECT '(3, 3)'::tid = '(3, 3)'::tid; + ?column? +---------- + t +(1 row) + +SELECT '(3, 3)'::tid <> '(3, 3)'::tid; + ?column? +---------- + f +(1 row) + +SELECT '(3, 3)'::tid <> '(3, 4)'::tid; + ?column? +---------- + t +(1 row) + ----------------------------------------------------------------------- Summary of changes: src/test/regress/expected/transactions_1.out | 561 ++++++++++++++++++++++++++ 1 files changed, 561 insertions(+), 0 deletions(-) create mode 100644 src/test/regress/expected/transactions_1.out hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-23 09:34:43
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 29637b7f7d32ea593f9d2689ec44a0c12511a274 (commit) from aa88067b97ebc92c9ab0a9995ad95e1f988b8df0 (commit) - Log ----------------------------------------------------------------- commit 29637b7f7d32ea593f9d2689ec44a0c12511a274 Author: Michael P <mic...@us...> Date: Wed Mar 23 18:33:53 2011 +0900 Fix for regression test union An ORDER BY was missing on a SELECT query. diff --git a/src/test/regress/expected/union_1.out b/src/test/regress/expected/union_1.out new file mode 100644 index 0000000..44d5f75 --- /dev/null +++ b/src/test/regress/expected/union_1.out @@ -0,0 +1,461 @@ +-- +-- UNION (also INTERSECT, EXCEPT) +-- +-- Simple UNION constructs +SELECT 1 AS two UNION SELECT 2 ORDER BY 1; + two +----- + 1 + 2 +(2 rows) + +SELECT 1 AS one UNION SELECT 1 ORDER BY 1; + one +----- + 1 +(1 row) + +SELECT 1 AS two UNION ALL SELECT 2 ORDER BY 1; + two +----- + 1 + 2 +(2 rows) + +SELECT 1 AS two UNION ALL SELECT 1 ORDER BY 1; + two +----- + 1 + 1 +(2 rows) + +SELECT 1 AS three UNION SELECT 2 UNION SELECT 3 ORDER BY 1; + three +------- + 1 + 2 + 3 +(3 rows) + +SELECT 1 AS two UNION SELECT 2 UNION SELECT 2 ORDER BY 1; + two +----- + 1 + 2 +(2 rows) + +SELECT 1 AS three UNION SELECT 2 UNION ALL SELECT 2 ORDER BY 1; + three +------- + 1 + 2 + 2 +(3 rows) + +SELECT 1.1 AS two UNION SELECT 2.2 ORDER BY 1; + two +----- + 1.1 + 2.2 +(2 rows) + +-- Mixed types +SELECT 1.1 AS two UNION SELECT 2 ORDER BY 1; + two +----- + 1.1 + 2 +(2 rows) + +SELECT 1 AS two UNION SELECT 2.2 ORDER BY 1; + two +----- + 1 + 2.2 +(2 rows) + +SELECT 1 AS one UNION SELECT 1.0::float8 ORDER BY 1; + one +----- + 1 +(1 row) + +SELECT 1.1 AS two UNION ALL SELECT 2 ORDER BY 1; + two +----- + 1.1 + 2 +(2 rows) + +SELECT 1.0::float8 AS two UNION ALL SELECT 1 ORDER BY 1; + two +----- + 1 + 1 +(2 rows) + +SELECT 1.1 AS three UNION SELECT 2 UNION SELECT 3 ORDER BY 1; + three +------- + 1.1 + 2 + 3 +(3 rows) + +SELECT 1.1::float8 AS two UNION SELECT 2 UNION SELECT 2.0::float8 ORDER BY 1; + two +----- + 1.1 + 2 +(2 rows) + +SELECT 1.1 AS three UNION SELECT 2 UNION ALL SELECT 2 ORDER BY 1; + three +------- + 1.1 + 2 + 2 +(3 rows) + +SELECT 1.1 AS two UNION (SELECT 2 UNION ALL SELECT 2) ORDER BY 1; + two +----- + 1.1 + 2 +(2 rows) + +-- +-- Try testing from tables... +-- +SELECT f1 AS five FROM FLOAT8_TBL +UNION +SELECT f1 FROM FLOAT8_TBL +ORDER BY 1; + five +----------------------- + -1.2345678901234e+200 + -1004.3 + -34.84 + -1.2345678901234e-200 + 0 +(5 rows) + +SELECT f1 AS ten FROM FLOAT8_TBL +UNION ALL +SELECT f1 FROM FLOAT8_TBL +ORDER BY 1; + ten +----------------------- + -1.2345678901234e+200 + -1.2345678901234e+200 + -1004.3 + -1004.3 + -34.84 + -34.84 + -1.2345678901234e-200 + -1.2345678901234e-200 + 0 + 0 +(10 rows) + +SELECT f1 AS nine FROM FLOAT8_TBL +UNION +SELECT f1 FROM INT4_TBL +ORDER BY 1; + nine +----------------------- + -1.2345678901234e+200 + -2147483647 + -123456 + -1004.3 + -34.84 + -1.2345678901234e-200 + 0 + 123456 + 2147483647 +(9 rows) + +SELECT f1 AS ten FROM FLOAT8_TBL +UNION ALL +SELECT f1 FROM INT4_TBL +ORDER BY 1; + ten +----------------------- + -1.2345678901234e+200 + -2147483647 + -123456 + -1004.3 + -34.84 + -1.2345678901234e-200 + 0 + 0 + 123456 + 2147483647 +(10 rows) + +SELECT f1 AS five FROM FLOAT8_TBL + WHERE f1 BETWEEN -1e6 AND 1e6 +UNION +SELECT f1 FROM INT4_TBL + WHERE f1 BETWEEN 0 AND 1000000 + ORDER BY 1; + five +----------------------- + -1004.3 + -34.84 + -1.2345678901234e-200 + 0 + 123456 +(5 rows) + +SELECT CAST(f1 AS char(4)) AS three FROM VARCHAR_TBL +UNION +SELECT f1 FROM CHAR_TBL +ORDER BY 1; + three +------- + a + ab + abcd +(3 rows) + +SELECT f1 AS three FROM VARCHAR_TBL +UNION +SELECT CAST(f1 AS varchar) FROM CHAR_TBL +ORDER BY 1; + three +------- + a + ab + abcd +(3 rows) + +SELECT f1 AS eight FROM VARCHAR_TBL +UNION ALL +SELECT f1 FROM CHAR_TBL +ORDER BY 1; + eight +------- + a + a + ab + ab + abcd + abcd + abcd + abcd +(8 rows) + +SELECT f1 AS five FROM TEXT_TBL +UNION +SELECT f1 FROM VARCHAR_TBL +UNION +SELECT TRIM(TRAILING FROM f1) FROM CHAR_TBL +ORDER BY 1; + five +------------------- + a + ab + abcd + doh! + hi de ho neighbor +(5 rows) + +-- +-- INTERSECT and EXCEPT +-- +SELECT q2 FROM int8_tbl INTERSECT SELECT q1 FROM int8_tbl ORDER BY 1; + q2 +------------------ + 123 + 4567890123456789 +(2 rows) + +SELECT q2 FROM int8_tbl INTERSECT ALL SELECT q1 FROM int8_tbl ORDER BY 1; + q2 +------------------ + 123 + 4567890123456789 + 4567890123456789 +(3 rows) + +SELECT q2 FROM int8_tbl EXCEPT SELECT q1 FROM int8_tbl ORDER BY 1; + q2 +------------------- + -4567890123456789 + 456 +(2 rows) + +SELECT q2 FROM int8_tbl EXCEPT ALL SELECT q1 FROM int8_tbl ORDER BY 1; + q2 +------------------- + -4567890123456789 + 456 +(2 rows) + +SELECT q2 FROM int8_tbl EXCEPT ALL SELECT DISTINCT q1 FROM int8_tbl ORDER BY 1; + q2 +------------------- + -4567890123456789 + 456 + 4567890123456789 +(3 rows) + +SELECT q1 FROM int8_tbl EXCEPT SELECT q2 FROM int8_tbl ORDER BY 1; + q1 +---- +(0 rows) + +SELECT q1 FROM int8_tbl EXCEPT ALL SELECT q2 FROM int8_tbl ORDER BY 1; + q1 +------------------ + 123 + 4567890123456789 +(2 rows) + +SELECT q1 FROM int8_tbl EXCEPT ALL SELECT DISTINCT q2 FROM int8_tbl ORDER BY 1; + q1 +------------------ + 123 + 4567890123456789 + 4567890123456789 +(3 rows) + +-- +-- Mixed types +-- +SELECT f1 FROM float8_tbl INTERSECT SELECT f1 FROM int4_tbl ORDER BY 1; + f1 +---- + 0 +(1 row) + +SELECT f1 FROM float8_tbl EXCEPT SELECT f1 FROM int4_tbl ORDER BY 1; + f1 +----------------------- + -1.2345678901234e+200 + -1004.3 + -34.84 + -1.2345678901234e-200 +(4 rows) + +-- +-- Operator precedence and (((((extra))))) parentheses +-- +SELECT q1 FROM int8_tbl INTERSECT SELECT q2 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl ORDER BY 1; + q1 +------------------- + -4567890123456789 + 123 + 123 + 456 + 4567890123456789 + 4567890123456789 + 4567890123456789 +(7 rows) + +SELECT q1 FROM int8_tbl INTERSECT (((SELECT q2 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl))) ORDER BY 1; + q1 +------------------ + 123 + 4567890123456789 +(2 rows) + +(((SELECT q1 FROM int8_tbl INTERSECT SELECT q2 FROM int8_tbl))) UNION ALL SELECT q2 FROM int8_tbl ORDER BY 1; + q1 +------------------- + -4567890123456789 + 123 + 123 + 456 + 4567890123456789 + 4567890123456789 + 4567890123456789 +(7 rows) + +SELECT q1 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl EXCEPT SELECT q1 FROM int8_tbl ORDER BY 1; + q1 +------------------- + -4567890123456789 + 456 +(2 rows) + +SELECT q1 FROM int8_tbl UNION ALL (((SELECT q2 FROM int8_tbl EXCEPT SELECT q1 FROM int8_tbl ORDER BY 1))) ORDER BY 1; + q1 +------------------- + -4567890123456789 + 123 + 123 + 456 + 4567890123456789 + 4567890123456789 + 4567890123456789 +(7 rows) + +(((SELECT q1 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl))) EXCEPT SELECT q1 FROM int8_tbl ORDER BY 1; + q1 +------------------- + -4567890123456789 + 456 +(2 rows) + +-- +-- Subqueries with ORDER BY & LIMIT clauses +-- +-- In this syntax, ORDER BY/LIMIT apply to the result of the EXCEPT +SELECT q1,q2 FROM int8_tbl EXCEPT SELECT q2,q1 FROM int8_tbl +ORDER BY q2,q1; + q1 | q2 +------------------+------------------- + 4567890123456789 | -4567890123456789 + 123 | 456 +(2 rows) + +-- This should fail, because q2 isn't a name of an EXCEPT output column +SELECT q1 FROM int8_tbl EXCEPT SELECT q2 FROM int8_tbl ORDER BY q2 LIMIT 1; +ERROR: column "q2" does not exist +LINE 1: ... int8_tbl EXCEPT SELECT q2 FROM int8_tbl ORDER BY q2 LIMIT 1... + ^ +-- But this should work: +SELECT q1 FROM int8_tbl EXCEPT (((SELECT q2 FROM int8_tbl ORDER BY q2 LIMIT 1))) ORDER BY q1; + q1 +------------------ + 123 + 4567890123456789 +(2 rows) + +-- +-- New syntaxes (7.1) permit new tests +-- +(((((select * from int8_tbl ORDER BY q1, q2))))); + q1 | q2 +------------------+------------------- + 123 | 456 + 123 | 4567890123456789 + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 + 4567890123456789 | 4567890123456789 +(5 rows) + +-- +-- Check handling of a case with unknown constants. We don't guarantee +-- an undecorated constant will work in all cases, but historically this +-- usage has worked, so test we don't break it. +-- +SELECT a.f1 FROM (SELECT 'test' AS f1 FROM varchar_tbl) a +UNION +SELECT b.f1 FROM (SELECT f1 FROM varchar_tbl) b +ORDER BY 1; + f1 +------ + a + ab + abcd + test +(4 rows) + +-- This should fail, but it should produce an error cursor +SELECT '3.4'::numeric UNION SELECT 'foo'; +ERROR: invalid input syntax for type numeric: "foo" +LINE 1: SELECT '3.4'::numeric UNION SELECT 'foo'; + ^ diff --git a/src/test/regress/sql/union.sql b/src/test/regress/sql/union.sql index 03f7f70..78f166e 100644 --- a/src/test/regress/sql/union.sql +++ b/src/test/regress/sql/union.sql @@ -149,7 +149,7 @@ ORDER BY q2,q1; SELECT q1 FROM int8_tbl EXCEPT SELECT q2 FROM int8_tbl ORDER BY q2 LIMIT 1; -- But this should work: -SELECT q1 FROM int8_tbl EXCEPT (((SELECT q2 FROM int8_tbl ORDER BY q2 LIMIT 1))); +SELECT q1 FROM int8_tbl EXCEPT (((SELECT q2 FROM int8_tbl ORDER BY q2 LIMIT 1))) ORDER BY q1; -- -- New syntaxes (7.1) permit new tests ----------------------------------------------------------------------- Summary of changes: .../regress/expected/{union.out => union_1.out} | 4 ++-- src/test/regress/sql/union.sql | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) copy src/test/regress/expected/{union.out => union_1.out} (99%) hooks/post-receive -- Postgres-XC |