@@ -432,7 +432,9 @@ crosstab(PG_FUNCTION_ARGS)
432432 break ;
433433 default :
434434 /* result type isn't composite */
435- elog (ERROR , "return type must be a row type" );
435+ ereport (ERROR ,
436+ (errcode (ERRCODE_DATATYPE_MISMATCH ),
437+ errmsg ("return type must be a row type" )));
436438 break ;
437439 }
438440
@@ -1350,7 +1352,9 @@ build_tuplestore_recursively(char *key_fld,
13501352 appendStringInfo (& chk_current_key , "%s%s%s" ,
13511353 branch_delim , current_key , branch_delim );
13521354 if (strstr (chk_branchstr .data , chk_current_key .data ))
1353- elog (ERROR , "infinite recursion detected" );
1355+ ereport (ERROR ,
1356+ (errcode (ERRCODE_INVALID_RECURSION ),
1357+ errmsg ("infinite recursion detected" )));
13541358 }
13551359
13561360 /* OK, extend the branch */
@@ -1429,7 +1433,7 @@ validateConnectbyTupleDesc(TupleDesc tupdesc, bool show_branch, bool show_serial
14291433 {
14301434 if (tupdesc -> natts != (CONNECTBY_NCOLS + serial_column ))
14311435 ereport (ERROR ,
1432- (errcode (ERRCODE_SYNTAX_ERROR ),
1436+ (errcode (ERRCODE_DATATYPE_MISMATCH ),
14331437 errmsg ("invalid return type" ),
14341438 errdetail ("Query-specified return tuple has " \
14351439 "wrong number of columns." )));
@@ -1438,7 +1442,7 @@ validateConnectbyTupleDesc(TupleDesc tupdesc, bool show_branch, bool show_serial
14381442 {
14391443 if (tupdesc -> natts != CONNECTBY_NCOLS_NOBRANCH + serial_column )
14401444 ereport (ERROR ,
1441- (errcode (ERRCODE_SYNTAX_ERROR ),
1445+ (errcode (ERRCODE_DATATYPE_MISMATCH ),
14421446 errmsg ("invalid return type" ),
14431447 errdetail ("Query-specified return tuple has " \
14441448 "wrong number of columns." )));
@@ -1447,35 +1451,41 @@ validateConnectbyTupleDesc(TupleDesc tupdesc, bool show_branch, bool show_serial
14471451 /* check that the types of the first two columns match */
14481452 if (tupdesc -> attrs [0 ]-> atttypid != tupdesc -> attrs [1 ]-> atttypid )
14491453 ereport (ERROR ,
1450- (errcode (ERRCODE_SYNTAX_ERROR ),
1454+ (errcode (ERRCODE_DATATYPE_MISMATCH ),
14511455 errmsg ("invalid return type" ),
14521456 errdetail ("First two columns must be the same type." )));
14531457
14541458 /* check that the type of the third column is INT4 */
14551459 if (tupdesc -> attrs [2 ]-> atttypid != INT4OID )
14561460 ereport (ERROR ,
1457- (errcode (ERRCODE_SYNTAX_ERROR ),
1461+ (errcode (ERRCODE_DATATYPE_MISMATCH ),
14581462 errmsg ("invalid return type" ),
14591463 errdetail ("Third column must be type %s." ,
14601464 format_type_be (INT4OID ))));
14611465
14621466 /* check that the type of the fourth column is TEXT if applicable */
14631467 if (show_branch && tupdesc -> attrs [3 ]-> atttypid != TEXTOID )
14641468 ereport (ERROR ,
1465- (errcode (ERRCODE_SYNTAX_ERROR ),
1469+ (errcode (ERRCODE_DATATYPE_MISMATCH ),
14661470 errmsg ("invalid return type" ),
14671471 errdetail ("Fourth column must be type %s." ,
14681472 format_type_be (TEXTOID ))));
14691473
14701474 /* check that the type of the fifth column is INT4 */
14711475 if (show_branch && show_serial && tupdesc -> attrs [4 ]-> atttypid != INT4OID )
1472- elog (ERROR , "query-specified return tuple not valid for Connectby: "
1473- "fifth column must be type %s" , format_type_be (INT4OID ));
1476+ ereport (ERROR ,
1477+ (errcode (ERRCODE_DATATYPE_MISMATCH ),
1478+ errmsg ("query-specified return tuple not valid for Connectby: "
1479+ "fifth column must be type %s" ,
1480+ format_type_be (INT4OID ))));
14741481
14751482 /* check that the type of the fifth column is INT4 */
14761483 if (!show_branch && show_serial && tupdesc -> attrs [3 ]-> atttypid != INT4OID )
1477- elog (ERROR , "query-specified return tuple not valid for Connectby: "
1478- "fourth column must be type %s" , format_type_be (INT4OID ));
1484+ ereport (ERROR ,
1485+ (errcode (ERRCODE_DATATYPE_MISMATCH ),
1486+ errmsg ("query-specified return tuple not valid for Connectby: "
1487+ "fourth column must be type %s" ,
1488+ format_type_be (INT4OID ))));
14791489
14801490 /* OK, the tupdesc is valid for our purposes */
14811491}
@@ -1496,7 +1506,7 @@ compatConnectbyTupleDescs(TupleDesc ret_tupdesc, TupleDesc sql_tupdesc)
14961506 */
14971507 if (sql_tupdesc -> natts < 2 )
14981508 ereport (ERROR ,
1499- (errcode (ERRCODE_SYNTAX_ERROR ),
1509+ (errcode (ERRCODE_DATATYPE_MISMATCH ),
15001510 errmsg ("invalid return type" ),
15011511 errdetail ("Query must return at least two columns." )));
15021512
@@ -1511,7 +1521,7 @@ compatConnectbyTupleDescs(TupleDesc ret_tupdesc, TupleDesc sql_tupdesc)
15111521 if (ret_atttypid != sql_atttypid ||
15121522 (ret_atttypmod >= 0 && ret_atttypmod != sql_atttypmod ))
15131523 ereport (ERROR ,
1514- (errcode (ERRCODE_SYNTAX_ERROR ),
1524+ (errcode (ERRCODE_DATATYPE_MISMATCH ),
15151525 errmsg ("invalid return type" ),
15161526 errdetail ("SQL key field type %s does " \
15171527 "not match return key field type %s." ,
@@ -1525,7 +1535,7 @@ compatConnectbyTupleDescs(TupleDesc ret_tupdesc, TupleDesc sql_tupdesc)
15251535 if (ret_atttypid != sql_atttypid ||
15261536 (ret_atttypmod >= 0 && ret_atttypmod != sql_atttypmod ))
15271537 ereport (ERROR ,
1528- (errco
67E5
de (ERRCODE_SYNTAX_ERROR ),
1538+ (errcode (ERRCODE_DATATYPE_MISMATCH ),
15291539 errmsg ("invalid return type" ),
15301540 errdetail ("SQL parent key field type %s does " \
15311541 "not match return parent key field type %s." ,
@@ -1556,7 +1566,7 @@ compatCrosstabTupleDescs(TupleDesc ret_tupdesc, TupleDesc sql_tupdesc)
15561566 sql_atttypid = sql_tupdesc -> attrs [0 ]-> atttypid ;
15571567 if (ret_atttypid != sql_atttypid )
15581568 ereport (ERROR ,
1559- (errcode (ERRCODE_SYNTAX_ERROR ),
1569+ (errcode (ERRCODE_DATATYPE_MISMATCH ),
15601570 errmsg ("invalid return type" ),
15611571 errdetail ("SQL rowid datatype does not match " \
15621572 "return rowid datatype." )));
0 commit comments