mirror of
https://github.com/postgres/postgres.git
synced 2025-04-27 22:56:53 +03:00
Back out cleanup patch. Got old version and needs work.
Neil Conway
This commit is contained in:
parent
ed275aea42
commit
e2c007046f
@ -27,7 +27,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.166 2002/06/25 17:27:20 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.167 2002/06/25 17:58:10 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -62,14 +62,14 @@ static TupleTableSlot *ExecutePlan(EState *estate, Plan *plan,
|
|||||||
long numberTuples,
|
long numberTuples,
|
||||||
ScanDirection direction,
|
ScanDirection direction,
|
||||||
DestReceiver *destfunc);
|
DestReceiver *destfunc);
|
||||||
static void ExecSelect(TupleTableSlot *slot,
|
static void ExecRetrieve(TupleTableSlot *slot,
|
||||||
DestReceiver *destfunc,
|
DestReceiver *destfunc,
|
||||||
EState *estate);
|
EState *estate);
|
||||||
static void ExecInsert(TupleTableSlot *slot, ItemPointer tupleid,
|
static void ExecAppend(TupleTableSlot *slot, ItemPointer tupleid,
|
||||||
EState *estate);
|
EState *estate);
|
||||||
static void ExecDelete(TupleTableSlot *slot, ItemPointer tupleid,
|
static void ExecDelete(TupleTableSlot *slot, ItemPointer tupleid,
|
||||||
EState *estate);
|
EState *estate);
|
||||||
static void ExecUpdate(TupleTableSlot *slot, ItemPointer tupleid,
|
static void ExecReplace(TupleTableSlot *slot, ItemPointer tupleid,
|
||||||
EState *estate);
|
EState *estate);
|
||||||
static TupleTableSlot *EvalPlanQualNext(EState *estate);
|
static TupleTableSlot *EvalPlanQualNext(EState *estate);
|
||||||
static void EndEvalPlanQual(EState *estate);
|
static void EndEvalPlanQual(EState *estate);
|
||||||
@ -251,7 +251,7 @@ ExecCheckQueryPerms(CmdType operation, Query *parseTree, Plan *plan)
|
|||||||
ExecCheckRTPerms(parseTree->rtable, operation);
|
ExecCheckRTPerms(parseTree->rtable, operation);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Search for subplans and INSERT nodes to check their rangetables.
|
* Search for subplans and APPEND nodes to check their rangetables.
|
||||||
*/
|
*/
|
||||||
ExecCheckPlanPerms(plan, parseTree->rtable, operation);
|
ExecCheckPlanPerms(plan, parseTree->rtable, operation);
|
||||||
}
|
}
|
||||||
@ -583,7 +583,7 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate)
|
|||||||
/*
|
/*
|
||||||
* Get the tuple descriptor describing the type of tuples to return.
|
* Get the tuple descriptor describing the type of tuples to return.
|
||||||
* (this is especially important if we are creating a relation with
|
* (this is especially important if we are creating a relation with
|
||||||
* "SELECT INTO")
|
* "retrieve into")
|
||||||
*/
|
*/
|
||||||
tupType = ExecGetTupType(plan); /* tuple descriptor */
|
tupType = ExecGetTupType(plan); /* tuple descriptor */
|
||||||
|
|
||||||
@ -892,7 +892,7 @@ EndPlan(Plan *plan, EState *estate)
|
|||||||
* Retrieves all tuples if numberTuples is 0
|
* Retrieves all tuples if numberTuples is 0
|
||||||
*
|
*
|
||||||
* result is either a slot containing the last tuple in the case
|
* result is either a slot containing the last tuple in the case
|
||||||
* of a SELECT or NULL otherwise.
|
* of a RETRIEVE or NULL otherwise.
|
||||||
*
|
*
|
||||||
* Note: the ctid attribute is a 'junk' attribute that is removed before the
|
* Note: the ctid attribute is a 'junk' attribute that is removed before the
|
||||||
* user can see it
|
* user can see it
|
||||||
@ -1068,26 +1068,29 @@ lnext: ;
|
|||||||
|
|
||||||
slot = ExecStoreTuple(newTuple, /* tuple to store */
|
slot = ExecStoreTuple(newTuple, /* tuple to store */
|
||||||
junkfilter->jf_resultSlot, /* dest slot */
|
junkfilter->jf_resultSlot, /* dest slot */
|
||||||
InvalidBuffer, /* this tuple has no buffer */
|
InvalidBuffer, /* this tuple has no
|
||||||
|
* buffer */
|
||||||
true); /* tuple should be pfreed */
|
true); /* tuple should be pfreed */
|
||||||
}
|
} /* if (junkfilter... */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* now that we have a tuple, do the appropriate thing with it..
|
* now that we have a tuple, do the appropriate thing with it..
|
||||||
* either return it to the user, add it to a relation someplace,
|
* either return it to the user, add it to a relation someplace,
|
||||||
* delete it from a relation, or modify some of its attributes.
|
* delete it from a relation, or modify some of its attributes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
switch (operation)
|
switch (operation)
|
||||||
{
|
{
|
||||||
case CMD_SELECT:
|
case CMD_SELECT:
|
||||||
ExecSelect(slot, /* slot containing tuple */
|
ExecRetrieve(slot, /* slot containing tuple */
|
||||||
destfunc, /* destination's tuple-receiver obj */
|
destfunc, /* destination's tuple-receiver
|
||||||
estate);
|
* obj */
|
||||||
|
estate); /* */
|
||||||
result = slot;
|
result = slot;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_INSERT:
|
case CMD_INSERT:
|
||||||
ExecInsert(slot, tupleid, estate);
|
ExecAppend(slot, tupleid, estate);
|
||||||
result = NULL;
|
result = NULL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1097,7 +1100,7 @@ lnext: ;
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_UPDATE:
|
case CMD_UPDATE:
|
||||||
ExecUpdate(slot, tupleid, estate);
|
ExecReplace(slot, tupleid, estate);
|
||||||
result = NULL;
|
result = NULL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1118,23 +1121,23 @@ lnext: ;
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* here, result is either a slot containing a tuple in the case of a
|
* here, result is either a slot containing a tuple in the case of a
|
||||||
* SELECT or NULL otherwise.
|
* RETRIEVE or NULL otherwise.
|
||||||
*/
|
*/
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------
|
/* ----------------------------------------------------------------
|
||||||
* ExecSelect
|
* ExecRetrieve
|
||||||
*
|
*
|
||||||
* SELECTs are easy.. we just pass the tuple to the appropriate
|
* RETRIEVEs are easy.. we just pass the tuple to the appropriate
|
||||||
* print function. The only complexity is when we do a
|
* print function. The only complexity is when we do a
|
||||||
* "SELECT INTO", in which case we insert the tuple into
|
* "retrieve into", in which case we insert the tuple into
|
||||||
* the appropriate relation (note: this is a newly created relation
|
* the appropriate relation (note: this is a newly created relation
|
||||||
* so we don't need to worry about indices or locks.)
|
* so we don't need to worry about indices or locks.)
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
ExecSelect(TupleTableSlot *slot,
|
ExecRetrieve(TupleTableSlot *slot,
|
||||||
DestReceiver *destfunc,
|
DestReceiver *destfunc,
|
||||||
EState *estate)
|
EState *estate)
|
||||||
{
|
{
|
||||||
@ -1166,15 +1169,16 @@ ExecSelect(TupleTableSlot *slot,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------
|
/* ----------------------------------------------------------------
|
||||||
* ExecInsert
|
* ExecAppend
|
||||||
*
|
*
|
||||||
* INSERTs are trickier.. we have to insert the tuple into
|
* APPENDs are trickier.. we have to insert the tuple into
|
||||||
* the base relation and insert appropriate tuples into the
|
* the base relation and insert appropriate tuples into the
|
||||||
* index relations.
|
* index relations.
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ExecInsert(TupleTableSlot *slot,
|
ExecAppend(TupleTableSlot *slot,
|
||||||
ItemPointer tupleid,
|
ItemPointer tupleid,
|
||||||
EState *estate)
|
EState *estate)
|
||||||
{
|
{
|
||||||
@ -1223,7 +1227,7 @@ ExecInsert(TupleTableSlot *slot,
|
|||||||
* Check the constraints of the tuple
|
* Check the constraints of the tuple
|
||||||
*/
|
*/
|
||||||
if (resultRelationDesc->rd_att->constr)
|
if (resultRelationDesc->rd_att->constr)
|
||||||
ExecConstraints("ExecInsert", resultRelInfo, slot, estate);
|
ExecConstraints("ExecAppend", resultRelInfo, slot, estate);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* insert the tuple
|
* insert the tuple
|
||||||
@ -1255,7 +1259,7 @@ ExecInsert(TupleTableSlot *slot,
|
|||||||
/* ----------------------------------------------------------------
|
/* ----------------------------------------------------------------
|
||||||
* ExecDelete
|
* ExecDelete
|
||||||
*
|
*
|
||||||
* DELETE is like UPDATE, we delete the tuple and its
|
* DELETE is like append, we delete the tuple and its
|
||||||
* index tuples.
|
* index tuples.
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1342,18 +1346,18 @@ ldelete:;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------
|
/* ----------------------------------------------------------------
|
||||||
* ExecUpdate
|
* ExecReplace
|
||||||
*
|
*
|
||||||
* note: we can't run UPDATE queries with transactions
|
* note: we can't run replace queries with transactions
|
||||||
* off because UPDATEs are actually INSERTs and our
|
* off because replaces are actually appends and our
|
||||||
* scan will mistakenly loop forever, updating the tuple
|
* scan will mistakenly loop forever, replacing the tuple
|
||||||
* it just inserted.. This should be fixed but until it
|
* it just appended.. This should be fixed but until it
|
||||||
* is, we don't want to get stuck in an infinite loop
|
* is, we don't want to get stuck in an infinite loop
|
||||||
* which corrupts your database..
|
* which corrupts your database..
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
ExecUpdate(TupleTableSlot *slot,
|
ExecReplace(TupleTableSlot *slot,
|
||||||
ItemPointer tupleid,
|
ItemPointer tupleid,
|
||||||
EState *estate)
|
EState *estate)
|
||||||
{
|
{
|
||||||
@ -1369,7 +1373,7 @@ ExecUpdate(TupleTableSlot *slot,
|
|||||||
*/
|
*/
|
||||||
if (IsBootstrapProcessingMode())
|
if (IsBootstrapProcessingMode())
|
||||||
{
|
{
|
||||||
elog(WARNING, "ExecUpdate: UPDATE can't run without transactions");
|
elog(WARNING, "ExecReplace: replace can't run without transactions");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1420,7 +1424,7 @@ ExecUpdate(TupleTableSlot *slot,
|
|||||||
*/
|
*/
|
||||||
lreplace:;
|
lreplace:;
|
||||||
if (resultRelationDesc->rd_att->constr)
|
if (resultRelationDesc->rd_att->constr)
|
||||||
ExecConstraints("ExecUpdate", resultRelInfo, slot, estate);
|
ExecConstraints("ExecReplace", resultRelInfo, slot, estate);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* replace the heap tuple
|
* replace the heap tuple
|
||||||
@ -1468,7 +1472,7 @@ lreplace:;
|
|||||||
/*
|
/*
|
||||||
* Note: instead of having to update the old index tuples associated
|
* Note: instead of having to update the old index tuples associated
|
||||||
* with the heap tuple, all we do is form and insert new index tuples.
|
* with the heap tuple, all we do is form and insert new index tuples.
|
||||||
* This is because UPDATEs are actually DELETEs and INSERTs and index
|
* This is because replaces are actually deletes and inserts and index
|
||||||
* tuple deletion is done automagically by the vacuum daemon. All we
|
* tuple deletion is done automagically by the vacuum daemon. All we
|
||||||
* do is insert new index tuples. -cim 9/27/89
|
* do is insert new index tuples. -cim 9/27/89
|
||||||
*/
|
*/
|
||||||
@ -1477,7 +1481,7 @@ lreplace:;
|
|||||||
* process indices
|
* process indices
|
||||||
*
|
*
|
||||||
* heap_update updates a tuple in the base relation by invalidating it
|
* heap_update updates a tuple in the base relation by invalidating it
|
||||||
* and then inserting a new tuple to the relation. As a side effect,
|
* and then appending a new tuple to the relation. As a side effect,
|
||||||
* the tupleid of the new tuple is placed in the new tuple's t_ctid
|
* the tupleid of the new tuple is placed in the new tuple's t_ctid
|
||||||
* field. So we now insert index tuples using the new tupleid stored
|
* field. So we now insert index tuples using the new tupleid stored
|
||||||
* there.
|
* there.
|
||||||
@ -1550,7 +1554,7 @@ ExecRelCheck(ResultRelInfo *resultRelInfo,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ExecConstraints(const char *caller, ResultRelInfo *resultRelInfo,
|
ExecConstraints(char *caller, ResultRelInfo *resultRelInfo,
|
||||||
TupleTableSlot *slot, EState *estate)
|
TupleTableSlot *slot, EState *estate)
|
||||||
{
|
{
|
||||||
Relation rel = resultRelInfo->ri_RelationDesc;
|
Relation rel = resultRelInfo->ri_RelationDesc;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.84 2002/06/25 17:27:20 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.85 2002/06/25 17:58:10 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -18,7 +18,7 @@
|
|||||||
*
|
*
|
||||||
* ExecOpenIndices \
|
* ExecOpenIndices \
|
||||||
* ExecCloseIndices | referenced by InitPlan, EndPlan,
|
* ExecCloseIndices | referenced by InitPlan, EndPlan,
|
||||||
* ExecInsertIndexTuples / ExecInsert, ExecUpdate
|
* ExecInsertIndexTuples / ExecAppend, ExecReplace
|
||||||
*
|
*
|
||||||
* RegisterExprContextCallback Register function shutdown callback
|
* RegisterExprContextCallback Register function shutdown callback
|
||||||
* UnregisterExprContextCallback Deregister function shutdown callback
|
* UnregisterExprContextCallback Deregister function shutdown callback
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.86 2002/06/25 17:27:20 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.87 2002/06/25 17:58:10 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -154,11 +154,11 @@ cost_seqscan(Path *path, Query *root,
|
|||||||
*
|
*
|
||||||
* Given a guesstimated cache size, we estimate the actual I/O cost per page
|
* Given a guesstimated cache size, we estimate the actual I/O cost per page
|
||||||
* with the entirely ad-hoc equations:
|
* with the entirely ad-hoc equations:
|
||||||
* if relpages >= effective_cache_size:
|
* for rel_size <= effective_cache_size:
|
||||||
* random_page_cost * (1 - (effective_cache_size/relpages)/2)
|
* 1 + (random_page_cost/2-1) * (rel_size/effective_cache_size) ** 2
|
||||||
* if relpages < effective_cache_size:
|
* for rel_size >= effective_cache_size:
|
||||||
* 1 + (random_page_cost/2-1) * (relpages/effective_cache_size) ** 2
|
* random_page_cost * (1 - (effective_cache_size/rel_size)/2)
|
||||||
* These give the right asymptotic behavior (=> 1.0 as relpages becomes
|
* These give the right asymptotic behavior (=> 1.0 as rel_size becomes
|
||||||
* small, => random_page_cost as it becomes large) and meet in the middle
|
* small, => random_page_cost as it becomes large) and meet in the middle
|
||||||
* with the estimate that the cache is about 50% effective for a relation
|
* with the estimate that the cache is about 50% effective for a relation
|
||||||
* of the same size as effective_cache_size. (XXX this is probably all
|
* of the same size as effective_cache_size. (XXX this is probably all
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* prepkeyset.c
|
* prepkeyset.c
|
||||||
* Special preparation for keyset queries (KSQO).
|
* Special preperation for keyset queries.
|
||||||
*
|
*
|
||||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
@ -14,6 +14,12 @@
|
|||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
#include "optimizer/planmain.h"
|
#include "optimizer/planmain.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Node_Copy
|
||||||
|
* a macro to simplify calling of copyObject on the specified field
|
||||||
|
*/
|
||||||
|
#define Node_Copy(from, newnode, field) newnode->field = copyObject(from->field)
|
||||||
|
|
||||||
bool _use_keyset_query_optimizer = FALSE;
|
bool _use_keyset_query_optimizer = FALSE;
|
||||||
|
|
||||||
#ifdef ENABLE_KEY_SET_QUERY
|
#ifdef ENABLE_KEY_SET_QUERY
|
||||||
@ -49,20 +55,13 @@ static int TotalExpr;
|
|||||||
* a HAVING, or a GROUP BY. It must be a single table and have KSQO
|
* a HAVING, or a GROUP BY. It must be a single table and have KSQO
|
||||||
* set to 'on'.
|
* set to 'on'.
|
||||||
*
|
*
|
||||||
* The primary use of this transformation is to avoid the exponential
|
* The primary use of this transformation is to avoid the exponrntial
|
||||||
* memory consumption of cnfify() and to make use of index access
|
* memory consumption of cnfify() and to make use of index access
|
||||||
* methods.
|
* methods.
|
||||||
*
|
*
|
||||||
* daveh@insightdist.com 1998-08-31
|
* daveh@insightdist.com 1998-08-31
|
||||||
*
|
*
|
||||||
* May want to also prune out duplicate terms.
|
* May want to also prune out duplicate terms.
|
||||||
*
|
|
||||||
* XXX: this code is currently not compiled because it has not been
|
|
||||||
* updated to work with the re-implementation of UNION/INTERSECT/EXCEPT
|
|
||||||
* in PostgreSQL 7.1. However, it is of questionable value in any
|
|
||||||
* case, because it changes the semantics of the original query:
|
|
||||||
* UNION will add an implicit SELECT DISTINCT, which might change
|
|
||||||
* the results that are returned.
|
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
void
|
void
|
||||||
transformKeySetQuery(Query *origNode)
|
transformKeySetQuery(Query *origNode)
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: executor.h,v 1.67 2002/06/25 17:27:20 momjian Exp $
|
* $Id: executor.h,v 1.68 2002/06/25 17:58:10 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -52,7 +52,7 @@ extern TupleDesc ExecutorStart(QueryDesc *queryDesc, EState *estate);
|
|||||||
extern TupleTableSlot *ExecutorRun(QueryDesc *queryDesc, EState *estate,
|
extern TupleTableSlot *ExecutorRun(QueryDesc *queryDesc, EState *estate,
|
||||||
ScanDirection direction, long count);
|
ScanDirection direction, long count);
|
||||||
extern void ExecutorEnd(QueryDesc *queryDesc, EState *estate);
|
extern void ExecutorEnd(QueryDesc *queryDesc, EState *estate);
|
||||||
extern void ExecConstraints(const char *caller, ResultRelInfo *resultRelInfo,
|
extern void ExecConstraints(char *caller, ResultRelInfo *resultRelInfo,
|
||||||
TupleTableSlot *slot, EState *estate);
|
TupleTableSlot *slot, EState *estate);
|
||||||
extern TupleTableSlot *EvalPlanQual(EState *estate, Index rti,
|
extern TupleTableSlot *EvalPlanQual(EState *estate, Index rti,
|
||||||
ItemPointer tid);
|
ItemPointer tid);
|
||||||
|
@ -411,7 +411,7 @@ create table atacc1 ( test int );
|
|||||||
alter table atacc1 add constraint atacc_test1 check (test>3);
|
alter table atacc1 add constraint atacc_test1 check (test>3);
|
||||||
-- should fail
|
-- should fail
|
||||||
insert into atacc1 (test) values (2);
|
insert into atacc1 (test) values (2);
|
||||||
ERROR: ExecInsert: rejected due to CHECK constraint atacc_test1
|
ERROR: ExecAppend: rejected due to CHECK constraint atacc_test1
|
||||||
-- should succeed
|
-- should succeed
|
||||||
insert into atacc1 (test) values (4);
|
insert into atacc1 (test) values (4);
|
||||||
drop table atacc1;
|
drop table atacc1;
|
||||||
@ -436,7 +436,7 @@ create table atacc1 ( test int, test2 int, test3 int);
|
|||||||
alter table atacc1 add constraint atacc_test1 check (test+test2<test3*4);
|
alter table atacc1 add constraint atacc_test1 check (test+test2<test3*4);
|
||||||
-- should fail
|
-- should fail
|
||||||
insert into atacc1 (test,test2,test3) values (4,4,2);
|
insert into atacc1 (test,test2,test3) values (4,4,2);
|
||||||
ERROR: ExecInsert: rejected due to CHECK constraint atacc_test1
|
ERROR: ExecAppend: rejected due to CHECK constraint atacc_test1
|
||||||
-- should succeed
|
-- should succeed
|
||||||
insert into atacc1 (test,test2,test3) values (4,4,5);
|
insert into atacc1 (test,test2,test3) values (4,4,5);
|
||||||
drop table atacc1;
|
drop table atacc1;
|
||||||
@ -445,7 +445,7 @@ create table atacc1 (test int check (test>3), test2 int);
|
|||||||
alter table atacc1 add check (test2>test);
|
alter table atacc1 add check (test2>test);
|
||||||
-- should fail for $2
|
-- should fail for $2
|
||||||
insert into atacc1 (test2, test) values (3, 4);
|
insert into atacc1 (test2, test) values (3, 4);
|
||||||
ERROR: ExecInsert: rejected due to CHECK constraint $2
|
ERROR: ExecAppend: rejected due to CHECK constraint $2
|
||||||
drop table atacc1;
|
drop table atacc1;
|
||||||
-- inheritance related tests
|
-- inheritance related tests
|
||||||
create table atacc1 (test int);
|
create table atacc1 (test int);
|
||||||
@ -454,11 +454,11 @@ create table atacc3 (test3 int) inherits (atacc1, atacc2);
|
|||||||
alter table atacc2 add constraint foo check (test2>0);
|
alter table atacc2 add constraint foo check (test2>0);
|
||||||
-- fail and then succeed on atacc2
|
-- fail and then succeed on atacc2
|
||||||
insert into atacc2 (test2) values (-3);
|
insert into atacc2 (test2) values (-3);
|
||||||
ERROR: ExecInsert: rejected due to CHECK constraint foo
|
ERROR: ExecAppend: rejected due to CHECK constraint foo
|
||||||
insert into atacc2 (test2) values (3);
|
insert into atacc2 (test2) values (3);
|
||||||
-- fail and then succeed on atacc3
|
-- fail and then succeed on atacc3
|
||||||
insert into atacc3 (test2) values (-3);
|
insert into atacc3 (test2) values (-3);
|
||||||
ERROR: ExecInsert: rejected due to CHECK constraint foo
|
ERROR: ExecAppend: rejected due to CHECK constraint foo
|
||||||
insert into atacc3 (test2) values (3);
|
insert into atacc3 (test2) values (3);
|
||||||
drop table atacc3;
|
drop table atacc3;
|
||||||
drop table atacc2;
|
drop table atacc2;
|
||||||
@ -470,7 +470,7 @@ create table atacc3 (test3 int) inherits (atacc1, atacc2);
|
|||||||
alter table only atacc2 add constraint foo check (test2>0);
|
alter table only atacc2 add constraint foo check (test2>0);
|
||||||
-- fail and then succeed on atacc2
|
-- fail and then succeed on atacc2
|
||||||
insert into atacc2 (test2) values (-3);
|
insert into atacc2 (test2) values (-3);
|
||||||
ERROR: ExecInsert: rejected due to CHECK constraint foo
|
ERROR: ExecAppend: rejected due to CHECK constraint foo
|
||||||
insert into atacc2 (test2) values (3);
|
insert into atacc2 (test2) values (3);
|
||||||
-- both succeed on atacc3
|
-- both succeed on atacc3
|
||||||
insert into atacc3 (test2) values (-3);
|
insert into atacc3 (test2) values (-3);
|
||||||
@ -608,7 +608,7 @@ insert into atacc1 (test2, test) values (3, 3);
|
|||||||
insert into atacc1 (test2, test) values (2, 3);
|
insert into atacc1 (test2, test) values (2, 3);
|
||||||
ERROR: Cannot insert a duplicate key into unique index atacc1_pkey
|
ERROR: Cannot insert a duplicate key into unique index atacc1_pkey
|
||||||
insert into atacc1 (test2, test) values (1, NULL);
|
insert into atacc1 (test2, test) values (1, NULL);
|
||||||
ERROR: ExecInsert: Fail to add null value in not null attribute test
|
ERROR: ExecAppend: Fail to add null value in not null attribute test
|
||||||
drop table atacc1;
|
drop table atacc1;
|
||||||
-- alter table / alter column [set/drop] not null tests
|
-- alter table / alter column [set/drop] not null tests
|
||||||
-- try altering system catalogs, should fail
|
-- try altering system catalogs, should fail
|
||||||
@ -658,9 +658,9 @@ create table parent (a int);
|
|||||||
create table child (b varchar(255)) inherits (parent);
|
create table child (b varchar(255)) inherits (parent);
|
||||||
alter table parent alter a set not null;
|
alter table parent alter a set not null;
|
||||||
insert into parent values (NULL);
|
insert into parent values (NULL);
|
||||||
ERROR: ExecInsert: Fail to add null value in not null attribute a
|
ERROR: ExecAppend: Fail to add null value in not null attribute a
|
||||||
insert into child (a, b) values (NULL, 'foo');
|
insert into child (a, b) values (NULL, 'foo');
|
||||||
ERROR: ExecInsert: Fail to add null value in not null attribute a
|
ERROR: ExecAppend: Fail to add null value in not null attribute a
|
||||||
alter table parent alter a drop not null;
|
alter table parent alter a drop not null;
|
||||||
insert into parent values (NULL);
|
insert into parent values (NULL);
|
||||||
insert into child (a, b) values (NULL, 'foo');
|
insert into child (a, b) values (NULL, 'foo');
|
||||||
@ -671,14 +671,14 @@ ERROR: ALTER TABLE: Attribute "a" contains NULL values
|
|||||||
delete from parent;
|
delete from parent;
|
||||||
alter table only parent alter a set not null;
|
alter table only parent alter a set not null;
|
||||||
insert into parent values (NULL);
|
insert into parent values (NULL);
|
||||||
ERROR: ExecInsert: Fail to add null value in not null attribute a
|
ERROR: ExecAppend: Fail to add null value in not null attribute a
|
||||||
alter table child alter a set not null;
|
alter table child alter a set not null;
|
||||||
insert into child (a, b) values (NULL, 'foo');
|
insert into child (a, b) values (NULL, 'foo');
|
||||||
ERROR: ExecInsert: Fail to add null value in not null attribute a
|
ERROR: ExecAppend: Fail to add null value in not null attribute a
|
||||||
delete from child;
|
delete from child;
|
||||||
alter table child alter a set not null;
|
alter table child alter a set not null;
|
||||||
insert into child (a, b) values (NULL, 'foo');
|
insert into child (a, b) values (NULL, 'foo');
|
||||||
ERROR: ExecInsert: Fail to add null value in not null attribute a
|
ERROR: ExecAppend: Fail to add null value in not null attribute a
|
||||||
drop table child;
|
drop table child;
|
||||||
drop table parent;
|
drop table parent;
|
||||||
-- test setting and removing default values
|
-- test setting and removing default values
|
||||||
|
@ -142,7 +142,7 @@ INSERT INTO serialTest VALUES ('foo');
|
|||||||
INSERT INTO serialTest VALUES ('bar');
|
INSERT INTO serialTest VALUES ('bar');
|
||||||
INSERT INTO serialTest VALUES ('force', 100);
|
INSERT INTO serialTest VALUES ('force', 100);
|
||||||
INSERT INTO serialTest VALUES ('wrong', NULL);
|
INSERT INTO serialTest VALUES ('wrong', NULL);
|
||||||
ERROR: ExecInsert: Fail to add null value in not null attribute f2
|
ERROR: ExecAppend: Fail to add null value in not null attribute f2
|
||||||
SELECT * FROM serialTest;
|
SELECT * FROM serialTest;
|
||||||
f1 | f2
|
f1 | f2
|
||||||
-------+-----
|
-------+-----
|
||||||
@ -151,13 +151,3 @@ SELECT * FROM serialTest;
|
|||||||
force | 100
|
force | 100
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
CREATE SEQUENCE sequence_test;
|
|
||||||
BEGIN;
|
|
||||||
SELECT nextval('sequence_test');
|
|
||||||
nextval
|
|
||||||
---------
|
|
||||||
1
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
DROP SEQUENCE sequence_test;
|
|
||||||
END;
|
|
||||||
|
@ -88,14 +88,14 @@ create table nulltest
|
|||||||
, col4 dnull
|
, col4 dnull
|
||||||
);
|
);
|
||||||
INSERT INTO nulltest DEFAULT VALUES;
|
INSERT INTO nulltest DEFAULT VALUES;
|
||||||
ERROR: ExecInsert: Fail to add null value in not null attribute col1
|
ERROR: ExecAppend: Fail to add null value in not null attribute col1
|
||||||
INSERT INTO nulltest values ('a', 'b', 'c', 'd'); -- Good
|
INSERT INTO nulltest values ('a', 'b', 'c', 'd'); -- Good
|
||||||
INSERT INTO nulltest values (NULL, 'b', 'c', 'd');
|
INSERT INTO nulltest values (NULL, 'b', 'c', 'd');
|
||||||
ERROR: ExecInsert: Fail to add null value in not null attribute col1
|
ERROR: ExecAppend: Fail to add null value in not null attribute col1
|
||||||
INSERT INTO nulltest values ('a', NULL, 'c', 'd');
|
INSERT INTO nulltest values ('a', NULL, 'c', 'd');
|
||||||
ERROR: ExecInsert: Fail to add null value in not null attribute col2
|
ERROR: ExecAppend: Fail to add null value in not null attribute col2
|
||||||
INSERT INTO nulltest values ('a', 'b', NULL, 'd');
|
INSERT INTO nulltest values ('a', 'b', NULL, 'd');
|
||||||
ERROR: ExecInsert: Fail to add null value in not null attribute col3
|
ERROR: ExecAppend: Fail to add null value in not null attribute col3
|
||||||
INSERT INTO nulltest values ('a', 'b', 'c', NULL); -- Good
|
INSERT INTO nulltest values ('a', 'b', 'c', NULL); -- Good
|
||||||
select * from nulltest;
|
select * from nulltest;
|
||||||
col1 | col2 | col3 | col4
|
col1 | col2 | col3 | col4
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
--
|
--
|
||||||
create table inserttest (col1 int4, col2 int4 NOT NULL, col3 text default 'testing');
|
create table inserttest (col1 int4, col2 int4 NOT NULL, col3 text default 'testing');
|
||||||
insert into inserttest (col1, col2, col3) values (DEFAULT, DEFAULT, DEFAULT);
|
insert into inserttest (col1, col2, col3) values (DEFAULT, DEFAULT, DEFAULT);
|
||||||
ERROR: ExecInsert: Fail to add null value in not null attribute col2
|
ERROR: ExecAppend: Fail to add null value in not null attribute col2
|
||||||
insert into inserttest (col2, col3) values (3, DEFAULT);
|
insert into inserttest (col2, col3) values (3, DEFAULT);
|
||||||
insert into inserttest (col1, col2, col3) values (DEFAULT, 5, DEFAULT);
|
insert into inserttest (col1, col2, col3) values (DEFAULT, 5, DEFAULT);
|
||||||
insert into inserttest values (DEFAULT, 5, 'test');
|
insert into inserttest values (DEFAULT, 5, 'test');
|
||||||
|
@ -21,15 +21,6 @@ SELECT b, c FROM test_having
|
|||||||
3 | bbbb
|
3 | bbbb
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
-- HAVING is equivalent to WHERE in this case
|
|
||||||
SELECT b, c FROM test_having
|
|
||||||
GROUP BY b, c HAVING b = 3;
|
|
||||||
b | c
|
|
||||||
---+----------
|
|
||||||
3 | BBBB
|
|
||||||
3 | bbbb
|
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
SELECT lower(c), count(c) FROM test_having
|
SELECT lower(c), count(c) FROM test_having
|
||||||
GROUP BY lower(c) HAVING count(*) > 2 OR min(a) = max(a);
|
GROUP BY lower(c) HAVING count(*) > 2 OR min(a) = max(a);
|
||||||
lower | count
|
lower | count
|
||||||
|
@ -62,12 +62,12 @@ CREATE TABLE CHECK_TBL (x int,
|
|||||||
INSERT INTO CHECK_TBL VALUES (5);
|
INSERT INTO CHECK_TBL VALUES (5);
|
||||||
INSERT INTO CHECK_TBL VALUES (4);
|
INSERT INTO CHECK_TBL VALUES (4);
|
||||||
INSERT INTO CHECK_TBL VALUES (3);
|
INSERT INTO CHECK_TBL VALUES (3);
|
||||||
ERROR: ExecInsert: rejected due to CHECK constraint check_con
|
ERROR: ExecAppend: rejected due to CHECK constraint check_con
|
||||||
INSERT INTO CHECK_TBL VALUES (2);
|
INSERT INTO CHECK_TBL VALUES (2);
|
||||||
ERROR: ExecInsert: rejected due to CHECK constraint check_con
|
ERROR: ExecAppend: rejected due to CHECK constraint check_con
|
||||||
INSERT INTO CHECK_TBL VALUES (6);
|
INSERT INTO CHECK_TBL VALUES (6);
|
||||||
INSERT INTO CHECK_TBL VALUES (1);
|
INSERT INTO CHECK_TBL VALUES (1);
|
||||||
ERROR: ExecInsert: rejected due to CHECK constraint check_con
|
ERROR: ExecAppend: rejected due to CHECK constraint check_con
|
||||||
SELECT '' AS three, * FROM CHECK_TBL;
|
SELECT '' AS three, * FROM CHECK_TBL;
|
||||||
three | x
|
three | x
|
||||||
-------+---
|
-------+---
|
||||||
@ -82,13 +82,13 @@ CREATE TABLE CHECK2_TBL (x int, y text, z int,
|
|||||||
CHECK (x > 3 and y <> 'check failed' and z < 8));
|
CHECK (x > 3 and y <> 'check failed' and z < 8));
|
||||||
INSERT INTO CHECK2_TBL VALUES (4, 'check ok', -2);
|
INSERT INTO CHECK2_TBL VALUES (4, 'check ok', -2);
|
||||||
INSERT INTO CHECK2_TBL VALUES (1, 'x check failed', -2);
|
INSERT INTO CHECK2_TBL VALUES (1, 'x check failed', -2);
|
||||||
ERROR: ExecInsert: rejected due to CHECK constraint sequence_con
|
ERROR: ExecAppend: rejected due to CHECK constraint sequence_con
|
||||||
INSERT INTO CHECK2_TBL VALUES (5, 'z check failed', 10);
|
INSERT INTO CHECK2_TBL VALUES (5, 'z check failed', 10);
|
||||||
ERROR: ExecInsert: rejected due to CHECK constraint sequence_con
|
ERROR: ExecAppend: rejected due to CHECK constraint sequence_con
|
||||||
INSERT INTO CHECK2_TBL VALUES (0, 'check failed', -2);
|
INSERT INTO CHECK2_TBL VALUES (0, 'check failed', -2);
|
||||||
ERROR: ExecInsert: rejected due to CHECK constraint sequence_con
|
ERROR: ExecAppend: rejected due to CHECK constraint sequence_con
|
||||||
INSERT INTO CHECK2_TBL VALUES (6, 'check failed', 11);
|
INSERT INTO CHECK2_TBL VALUES (6, 'check failed', 11);
|
||||||
ERROR: ExecInsert: rejected due to CHECK constraint sequence_con
|
ERROR: ExecAppend: rejected due to CHECK constraint sequence_con
|
||||||
INSERT INTO CHECK2_TBL VALUES (7, 'check ok', 7);
|
INSERT INTO CHECK2_TBL VALUES (7, 'check ok', 7);
|
||||||
SELECT '' AS two, * from CHECK2_TBL;
|
SELECT '' AS two, * from CHECK2_TBL;
|
||||||
two | x | y | z
|
two | x | y | z
|
||||||
@ -107,7 +107,7 @@ CREATE TABLE INSERT_TBL (x INT DEFAULT nextval('insert_seq'),
|
|||||||
CONSTRAINT INSERT_CON CHECK (x >= 3 AND y <> 'check failed' AND x < 8),
|
CONSTRAINT INSERT_CON CHECK (x >= 3 AND y <> 'check failed' AND x < 8),
|
||||||
CHECK (x + z = 0));
|
CHECK (x + z = 0));
|
||||||
INSERT INTO INSERT_TBL(x,z) VALUES (2, -2);
|
INSERT INTO INSERT_TBL(x,z) VALUES (2, -2);
|
||||||
ERROR: ExecInsert: rejected due to CHECK constraint insert_con
|
ERROR: ExecAppend: rejected due to CHECK constraint insert_con
|
||||||
SELECT '' AS zero, * FROM INSERT_TBL;
|
SELECT '' AS zero, * FROM INSERT_TBL;
|
||||||
zero | x | y | z
|
zero | x | y | z
|
||||||
------+---+---+---
|
------+---+---+---
|
||||||
@ -120,13 +120,13 @@ SELECT 'one' AS one, nextval('insert_seq');
|
|||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
INSERT INTO INSERT_TBL(y) VALUES ('Y');
|
INSERT INTO INSERT_TBL(y) VALUES ('Y');
|
||||||
ERROR: ExecInsert: rejected due to CHECK constraint insert_con
|
ERROR: ExecAppend: rejected due to CHECK constraint insert_con
|
||||||
INSERT INTO INSERT_TBL(y) VALUES ('Y');
|
INSERT INTO INSERT_TBL(y) VALUES ('Y');
|
||||||
INSERT INTO INSERT_TBL(x,z) VALUES (1, -2);
|
INSERT INTO INSERT_TBL(x,z) VALUES (1, -2);
|
||||||
ERROR: ExecInsert: rejected due to CHECK constraint $2
|
ERROR: ExecAppend: rejected due to CHECK constraint $2
|
||||||
INSERT INTO INSERT_TBL(z,x) VALUES (-7, 7);
|
INSERT INTO INSERT_TBL(z,x) VALUES (-7, 7);
|
||||||
INSERT INTO INSERT_TBL VALUES (5, 'check failed', -5);
|
INSERT INTO INSERT_TBL VALUES (5, 'check failed', -5);
|
||||||
ERROR: ExecInsert: rejected due to CHECK constraint insert_con
|
ERROR: ExecAppend: rejected due to CHECK constraint insert_con
|
||||||
INSERT INTO INSERT_TBL VALUES (7, '!check failed', -7);
|
INSERT INTO INSERT_TBL VALUES (7, '!check failed', -7);
|
||||||
INSERT INTO INSERT_TBL(y) VALUES ('-!NULL-');
|
INSERT INTO INSERT_TBL(y) VALUES ('-!NULL-');
|
||||||
SELECT '' AS four, * FROM INSERT_TBL;
|
SELECT '' AS four, * FROM INSERT_TBL;
|
||||||
@ -139,9 +139,9 @@ SELECT '' AS four, * FROM INSERT_TBL;
|
|||||||
(4 rows)
|
(4 rows)
|
||||||
|
|
||||||
INSERT INTO INSERT_TBL(y,z) VALUES ('check failed', 4);
|
INSERT INTO INSERT_TBL(y,z) VALUES ('check failed', 4);
|
||||||
ERROR: ExecInsert: rejected due to CHECK constraint $2
|
ERROR: ExecAppend: rejected due to CHECK constraint $2
|
||||||
INSERT INTO INSERT_TBL(x,y) VALUES (5, 'check failed');
|
INSERT INTO INSERT_TBL(x,y) VALUES (5, 'check failed');
|
||||||
ERROR: ExecInsert: rejected due to CHECK constraint insert_con
|
ERROR: ExecAppend: rejected due to CHECK constraint insert_con
|
||||||
INSERT INTO INSERT_TBL(x,y) VALUES (5, '!check failed');
|
INSERT INTO INSERT_TBL(x,y) VALUES (5, '!check failed');
|
||||||
INSERT INTO INSERT_TBL(y) VALUES ('-!NULL-');
|
INSERT INTO INSERT_TBL(y) VALUES ('-!NULL-');
|
||||||
SELECT '' AS six, * FROM INSERT_TBL;
|
SELECT '' AS six, * FROM INSERT_TBL;
|
||||||
@ -162,7 +162,7 @@ SELECT 'seven' AS one, nextval('insert_seq');
|
|||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
INSERT INTO INSERT_TBL(y) VALUES ('Y');
|
INSERT INTO INSERT_TBL(y) VALUES ('Y');
|
||||||
ERROR: ExecInsert: rejected due to CHECK constraint insert_con
|
ERROR: ExecAppend: rejected due to CHECK constraint insert_con
|
||||||
SELECT 'eight' AS one, currval('insert_seq');
|
SELECT 'eight' AS one, currval('insert_seq');
|
||||||
one | currval
|
one | currval
|
||||||
-------+---------
|
-------+---------
|
||||||
@ -193,11 +193,11 @@ CREATE TABLE INSERT_CHILD (cx INT default 42,
|
|||||||
INHERITS (INSERT_TBL);
|
INHERITS (INSERT_TBL);
|
||||||
INSERT INTO INSERT_CHILD(x,z,cy) VALUES (7,-7,11);
|
INSERT INTO INSERT_CHILD(x,z,cy) VALUES (7,-7,11);
|
||||||
INSERT INTO INSERT_CHILD(x,z,cy) VALUES (7,-7,6);
|
INSERT INTO INSERT_CHILD(x,z,cy) VALUES (7,-7,6);
|
||||||
ERROR: ExecInsert: rejected due to CHECK constraint insert_child_cy
|
ERROR: ExecAppend: rejected due to CHECK constraint insert_child_cy
|
||||||
INSERT INTO INSERT_CHILD(x,z,cy) VALUES (6,-7,7);
|
INSERT INTO INSERT_CHILD(x,z,cy) VALUES (6,-7,7);
|
||||||
ERROR: ExecInsert: rejected due to CHECK constraint $1
|
ERROR: ExecAppend: rejected due to CHECK constraint $1
|
||||||
INSERT INTO INSERT_CHILD(x,y,z,cy) VALUES (6,'check failed',-6,7);
|
INSERT INTO INSERT_CHILD(x,y,z,cy) VALUES (6,'check failed',-6,7);
|
||||||
ERROR: ExecInsert: rejected due to CHECK constraint insert_con
|
ERROR: ExecAppend: rejected due to CHECK constraint insert_con
|
||||||
SELECT * FROM INSERT_CHILD;
|
SELECT * FROM INSERT_CHILD;
|
||||||
x | y | z | cx | cy
|
x | y | z | cx | cy
|
||||||
---+--------+----+----+----
|
---+--------+----+----+----
|
||||||
@ -227,7 +227,7 @@ SELECT '' AS three, * FROM INSERT_TBL;
|
|||||||
INSERT INTO INSERT_TBL SELECT * FROM tmp WHERE yd = 'try again';
|
INSERT INTO INSERT_TBL SELECT * FROM tmp WHERE yd = 'try again';
|
||||||
INSERT INTO INSERT_TBL(y,z) SELECT yd, -7 FROM tmp WHERE yd = 'try again';
|
INSERT INTO INSERT_TBL(y,z) SELECT yd, -7 FROM tmp WHERE yd = 'try again';
|
||||||
INSERT INTO INSERT_TBL(y,z) SELECT yd, -8 FROM tmp WHERE yd = 'try again';
|
INSERT INTO INSERT_TBL(y,z) SELECT yd, -8 FROM tmp WHERE yd = 'try again';
|
||||||
ERROR: ExecInsert: rejected due to CHECK constraint insert_con
|
ERROR: ExecAppend: rejected due to CHECK constraint insert_con
|
||||||
SELECT '' AS four, * FROM INSERT_TBL;
|
SELECT '' AS four, * FROM INSERT_TBL;
|
||||||
four | x | y | z
|
four | x | y | z
|
||||||
------+---+---------------+----
|
------+---+---------------+----
|
||||||
@ -246,7 +246,7 @@ UPDATE INSERT_TBL SET x = NULL WHERE x = 5;
|
|||||||
UPDATE INSERT_TBL SET x = 6 WHERE x = 6;
|
UPDATE INSERT_TBL SET x = 6 WHERE x = 6;
|
||||||
UPDATE INSERT_TBL SET x = -z, z = -x;
|
UPDATE INSERT_TBL SET x = -z, z = -x;
|
||||||
UPDATE INSERT_TBL SET x = z, z = x;
|
UPDATE INSERT_TBL SET x = z, z = x;
|
||||||
ERROR: ExecUpdate: rejected due to CHECK constraint insert_con
|
ERROR: ExecReplace: rejected due to CHECK constraint insert_con
|
||||||
SELECT * FROM INSERT_TBL;
|
SELECT * FROM INSERT_TBL;
|
||||||
x | y | z
|
x | y | z
|
||||||
---+---------------+----
|
---+---------------+----
|
||||||
@ -293,7 +293,7 @@ ERROR: Cannot insert a duplicate key into unique index primary_tbl_pkey
|
|||||||
INSERT INTO PRIMARY_TBL VALUES (4, 'three');
|
INSERT INTO PRIMARY_TBL VALUES (4, 'three');
|
||||||
INSERT INTO PRIMARY_TBL VALUES (5, 'one');
|
INSERT INTO PRIMARY_TBL VALUES (5, 'one');
|
||||||
INSERT INTO PRIMARY_TBL (t) VALUES ('six');
|
INSERT INTO PRIMARY_TBL (t) VALUES ('six');
|
||||||
ERROR: ExecInsert: Fail to add null value in not null attribute i
|
ERROR: ExecAppend: Fail to add null value in not null attribute i
|
||||||
SELECT '' AS four, * FROM PRIMARY_TBL;
|
SELECT '' AS four, * FROM PRIMARY_TBL;
|
||||||
four | i | t
|
four | i | t
|
||||||
------+---+-------
|
------+---+-------
|
||||||
@ -313,7 +313,7 @@ INSERT INTO PRIMARY_TBL VALUES (1, 'three');
|
|||||||
INSERT INTO PRIMARY_TBL VALUES (4, 'three');
|
INSERT INTO PRIMARY_TBL VALUES (4, 'three');
|
||||||
INSERT INTO PRIMARY_TBL VALUES (5, 'one');
|
INSERT INTO PRIMARY_TBL VALUES (5, 'one');
|
||||||
INSERT INTO PRIMARY_TBL (t) VALUES ('six');
|
INSERT INTO PRIMARY_TBL (t) VALUES ('six');
|
||||||
ERROR: ExecInsert: Fail to add null value in not null attribute i
|
ERROR: ExecAppend: Fail to add null value in not null attribute i
|
||||||
SELECT '' AS three, * FROM PRIMARY_TBL;
|
SELECT '' AS three, * FROM PRIMARY_TBL;
|
||||||
three | i | t
|
three | i | t
|
||||||
-------+---+-------
|
-------+---+-------
|
||||||
|
@ -217,10 +217,3 @@ INSERT INTO serialTest VALUES ('force', 100);
|
|||||||
INSERT INTO serialTest VALUES ('wrong', NULL);
|
INSERT INTO serialTest VALUES ('wrong', NULL);
|
||||||
|
|
||||||
SELECT * FROM serialTest;
|
SELECT * FROM serialTest;
|
||||||
|
|
||||||
CREATE SEQUENCE sequence_test;
|
|
||||||
|
|
||||||
BEGIN;
|
|
||||||
SELECT nextval('sequence_test');
|
|
||||||
DROP SEQUENCE sequence_test;
|
|
||||||
END;
|
|
||||||
|
@ -18,10 +18,6 @@ INSERT INTO test_having VALUES (9, 4, 'CCCC', 'j');
|
|||||||
SELECT b, c FROM test_having
|
SELECT b, c FROM test_having
|
||||||
GROUP BY b, c HAVING count(*) = 1;
|
GROUP BY b, c HAVING count(*) = 1;
|
||||||
|
|
||||||
-- HAVING is equivalent to WHERE in this case
|
|
||||||
SELECT b, c FROM test_having
|
|
||||||
GROUP BY b, c HAVING b = 3;
|
|
||||||
|
|
||||||
SELECT lower(c), count(c) FROM test_having
|
SELECT lower(c), count(c) FROM test_having
|
||||||
GROUP BY lower(c) HAVING count(*) > 2 OR min(a) = max(a);
|
GROUP BY lower(c) HAVING count(*) > 2 OR min(a) = max(a);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user