6868#include "utils/ruleutils.h"
6969#include "utils/syscache.h"
7070#include "utils/typcache.h"
71- #include <math.h>
71+ #include <math.h>
7272#include "utils/guc.h"
7373#include "utils/ora_compatible.h"
7474
@@ -280,10 +280,12 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
280280 if (cxt .inhRelations )
281281 {
282282 ListCell * inher ;
283+
283284 foreach (inher , cxt .inhRelations )
284285 {
285286 RangeVar * inh = lfirst_node (RangeVar , inher );
286287 Relation prel ;
288+
287289 prel = table_openrv (inh , AccessShareLock );
288290 cxt .hasrowid = cxt .hasrowid || prel -> rd_rel -> relhasrowid ;
289291 table_close (prel , NoLock );
@@ -302,7 +304,8 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
302304 {
303305 case T_ColumnDef :
304306 {
305- ColumnDef * col = (ColumnDef * ) element ;
307+ ColumnDef * col = (ColumnDef * ) element ;
308+
306309 if (compatible_db == ORA_PARSER && strcmp (col -> colname , "rowid" ) == 0 )
307310 elog (ERROR , "column name \"%s\" conflicts with a system column name" , col -> colname );
308311 else
@@ -331,13 +334,14 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
331334 */
332335 foreach (elements , cxt .columns )
333336 {
334- ColumnDef * element = lfirst (elements );
335- if (element -> identity == ATTRIBUTE_IDENTITY_DEFAULT_ON_NULL ||
336- element -> identity == ATTRIBUTE_ORA_IDENTITY_ALWAYS ||
337- element -> identity == ATTRIBUTE_ORA_IDENTITY_BY_DEFAULT )
337+ ColumnDef * element = lfirst (elements );
338+
339+ if (element -> identity == ATTRIBUTE_IDENTITY_DEFAULT_ON_NULL ||
340+ element -> identity == ATTRIBUTE_ORA_IDENTITY_ALWAYS ||
341+ element -> identity == ATTRIBUTE_ORA_IDENTITY_BY_DEFAULT )
338342 ora_identity_cnt ++ ;
339343 }
340- if (ora_identity_cnt > 1 )
344+ if (ora_identity_cnt > 1 )
341345 elog (ERROR , "table can have only one identity column" );
342346
343347 if (like_found && cxt .hasrowid )
@@ -348,7 +352,7 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
348352
349353 if (cxt .hasrowid )
350354 {
351- Oid snamespaceid ;
355+ Oid snamespaceid ;
352356 char * snamespace ;
353357 char * sname ;
354358
@@ -368,47 +372,48 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
368372 false);
369373
370374 /*
371- * Build a CREATE SEQUENCE command to create the sequence object,
372- * and add it to the list of things to be done before this CREATE/ALTER TABLE
375+ * Build a CREATE SEQUENCE command to create the sequence object, and
376+ * add it to the list of things to be done before this CREATE/ALTER
377+ * TABLE
373378 */
374379 seqstmt = makeNode (CreateSeqStmt );
375380 seqstmt -> with_rowid = true;
376381 seqstmt -> sequence = makeRangeVar (snamespace , sname , -1 );
377382 seqstmt -> options = lcons (makeDefElem ("as" ,
378- (Node * ) makeTypeNameFromOid (INT8OID , -1 ),
379- -1 ),
380- seqstmt -> options );
383+ (Node * ) makeTypeNameFromOid (INT8OID , -1 ),
384+ -1 ),
385+ seqstmt -> options );
381386 if (rowid_seq_cache > 1 )
382387 {
383388 seqstmt -> options = lcons (makeDefElem ("cache" ,
384- (Node * ) makeInteger (rowid_seq_cache ),
385- -1 ),
386- seqstmt -> options );
389+ (Node * ) makeInteger (rowid_seq_cache ),
390+ -1 ),
391+ seqstmt -> options );
387392 }
388393 else
389394 seqstmt -> options = lcons (makeDefElem ("nocache" ,
390- NULL ,
391- -1 ),
392- seqstmt -> options );
395+ NULL ,
396+ -1 ),
397+ seqstmt -> options );
393398
394399 if (cxt .rel )
395400 seqstmt -> ownerId = cxt .rel -> rd_rel -> relowner ;
396401
397402 cxt .blist = lappend (cxt .blist , seqstmt );
398403
399404 /*
400- * Build an ALTER SEQUENCE ... OWNED BY command to mark the sequence as owned
401- * by this table.
405+ * Build an ALTER SEQUENCE ... OWNED BY command to mark the sequence
406+ * as owned by this table.
402407 */
403408 altseqstmt = makeNode (AlterSeqStmt );
404409 altseqstmt -> sequence = makeRangeVar (snamespace , sname , -1 );
405410
406411 relnamelist = list_make3 (makeString (snamespace ),
407- makeString (cxt .relation -> relname ),
408- makeString (sname ));
412+ makeString (cxt .relation -> relname ),
413+ makeString (sname ));
409414
410415 altseqstmt -> options = list_make1 (makeDefElem ("owned_by" ,
411- (Node * ) relnamelist , -1 ));
416+ (Node * ) relnamelist , -1 ));
412417 cxt .alist = lappend (cxt .alist , altseqstmt );
413418 }
414419
@@ -971,11 +976,14 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column)
971976 ctype = typenameType (cxt -> pstate , column -> typeName , & typmod );
972977 typeOid = ((Form_pg_type ) GETSTRUCT (ctype ))-> oid ;
973978
974- /* Convert compatible identity smallint/int type column to bigint type */
979+ /*
980+ * Convert compatible identity smallint/int type column to
981+ * bigint type
982+ */
975983 if ((constraint -> generated_when == ATTRIBUTE_IDENTITY_DEFAULT_ON_NULL
976- || constraint -> generated_when == ATTRIBUTE_ORA_IDENTITY_ALWAYS
977- || constraint -> generated_when == ATTRIBUTE_ORA_IDENTITY_BY_DEFAULT )
978- && (typeOid == INT4OID || typeOid == INT2OID ))
984+ || constraint -> generated_when == ATTRIBUTE_ORA_IDENTITY_ALWAYS
985+ || constraint -> generated_when == ATTRIBUTE_ORA_IDENTITY_BY_DEFAULT )
986+ && (typeOid == INT4OID || typeOid == INT2OID ))
979987 {
980988 column -> typeName = makeTypeName ("int8" );
981989 typeOid = INT8OID ;
@@ -1296,7 +1304,7 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
12961304 if (relation -> rd_rel -> relkind == RELKIND_COMPOSITE_TYPE )
12971305 {
12981306 aclresult = object_aclcheck (TypeRelationId , relation -> rd_rel -> reltype , GetUserId (),
1299- ACL_USAGE );
1307+ ACL_USAGE );
13001308 if (aclresult != ACLCHECK_OK )
13011309 aclcheck_error (aclresult , OBJECT_TYPE ,
13021310 RelationGetRelationName (relation ));
@@ -2689,7 +2697,7 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
26892697 * mentioned above.
26902698 */
26912699 Datum attoptions =
2692- get_attoptions (RelationGetRelid (index_rel ), i + 1 );
2700+ get_attoptions (RelationGetRelid (index_rel ), i + 1 );
26932701
26942702 defopclass = GetDefaultOpClass (attform -> atttypid ,
26952703 index_rel -> rd_rel -> relam );
@@ -3764,12 +3772,12 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt,
37643772
37653773 case AT_AddRowidsRecurse :
37663774 {
3767- Oid snamespaceid ;
3768- char * snamespace ;
3769- char * sname ;
3770- List * relnamelist ;
3771- CreateSeqStmt * seqstmt ;
3772- AlterSeqStmt * altseqstmt ;
3775+ Oid snamespaceid ;
3776+ char * snamespace ;
3777+ char * sname ;
3778+ List * relnamelist ;
3779+ CreateSeqStmt * seqstmt ;
3780+ AlterSeqStmt * altseqstmt ;
37733781
37743782 if (cmd -> is_rowid )
37753783 {
@@ -3789,45 +3797,46 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt,
37893797 false);
37903798
37913799 /*
3792- * Build a CREATE SEQUENCE command to create the sequence object,
3793- * and add it to the list of things to be done before this CREATE/ALTER TABLE
3800+ * Build a CREATE SEQUENCE command to create the
3801+ * sequence object, and add it to the list of things
3802+ * to be done before this CREATE/ALTER TABLE
37943803 */
37953804 seqstmt = makeNode (CreateSeqStmt );
37963805 seqstmt -> with_rowid = true;
37973806 seqstmt -> sequence = makeRangeVar (snamespace , sname , -1 );
37983807 seqstmt -> options = lcons (makeDefElem ("as" ,
3799- (Node * ) makeTypeNameFromOid (INT8OID , -1 ),
3800- -1 ), seqstmt -> options );
3808+ (Node * ) makeTypeNameFromOid (INT8OID , -1 ),
3809+ -1 ), seqstmt -> options );
38013810 if (rowid_seq_cache > 1 )
38023811 {
38033812 seqstmt -> options = lcons (makeDefElem ("cache" ,
3804- (Node * ) makeInteger (rowid_seq_cache ),
3805- -1 ), seqstmt -> options );
3813+ (Node * ) makeInteger (rowid_seq_cache ),
3814+ -1 ), seqstmt -> options );
38063815 }
38073816 else
38083817 seqstmt -> options = lcons (makeDefElem ("nocache" ,
3809- NULL ,
3810- -1 ),
3811- seqstmt -> options );
3818+ NULL ,
3819+ -1 ),
3820+ seqstmt -> options );
38123821
38133822 if (cxt .rel )
38143823 seqstmt -> ownerId = cxt .rel -> rd_rel -> relowner ;
38153824
38163825 cxt .blist = lappend (cxt .blist , seqstmt );
38173826
38183827 /*
3819- * Build an ALTER SEQUENCE ... OWNED BY command to mark the sequence as owned
3820- * by this table.
3828+ * Build an ALTER SEQUENCE ... OWNED BY command to
3829+ * mark the sequence as owned by this table.
38213830 */
38223831 altseqstmt = makeNode (AlterSeqStmt );
38233832 altseqstmt -> sequence = makeRangeVar (snamespace , sname , -1 );
38243833
38253834 relnamelist = list_make3 (makeString (snamespace ),
3826- makeString (cxt .relation -> relname ),
3827- makeString (sname ));
3835+ makeString (cxt .relation -> relname ),
3836+ makeString (sname ));
38283837
38293838 altseqstmt -> options = list_make1 (makeDefElem ("owned_by" ,
3830- (Node * ) relnamelist , -1 ));
3839+ (Node * ) relnamelist , -1 ));
38313840 cxt .alist = lappend (cxt .alist , altseqstmt );
38323841
38333842 newcmds = lappend (newcmds , cmd );
@@ -4669,7 +4678,7 @@ transformPartitionRangeBounds(ParseState *pstate, List *blist,
46694678 * as ColumnRefs.
46704679 */
46714680 if (IsA (expr , ColumnRef ) ||
4672- IsA (expr , ColumnRefOrFuncCall ))
4681+ IsA (expr , ColumnRefOrFuncCall ))
46734682 {
46744683 ColumnRef * cref = NULL ;
46754684 char * cname = NULL ;
0 commit comments