Skip to content

Commit a44a44c

Browse files
author
anju15bharti
committed
fix failures
1 parent 7e44df2 commit a44a44c

7 files changed

Lines changed: 135 additions & 58 deletions

File tree

contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--6.1.0--6.2.0.sql

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,6 @@ and p.prokind = 'f'
423423
and format_type(p.prorettype, null) = 'trigger';
424424
GRANT SELECT ON sys.triggers TO PUBLIC;
425425

426-
CREATE OR REPLACE FUNCTION sys.columns_internal()
427426

428427
CREATE OR REPLACE VIEW sys.sp_special_columns_view AS
429428
SELECT
@@ -596,7 +595,6 @@ WHERE nspname = 'sys' AND (proname LIKE 'sp\_%' OR proname LIKE 'xp\_%' OR prona
596595

597596
GRANT SELECT ON sys.sp_stored_procedures_view TO PUBLIC;
598597

599-
CREATE OR REPLACE FUNCTION sys.columns_internal()
600598

601599
create or replace view sys.databases as
602600
select
@@ -697,50 +695,6 @@ select
697695
LEFT OUTER JOIN pg_catalog.pg_collation c ON d.default_collation = c.collname;
698696
GRANT SELECT ON sys.databases TO PUBLIC;
699697

700-
CREATE OR REPLACE FUNCTION sys.columns_internal()
701-
RETURNS TABLE (
702-
out_object_id int,
703-
out_name sys.sysname,
704-
out_column_id int,
705-
out_system_type_id int,
706-
out_user_type_id int,
707-
out_max_length smallint,
708-
out_precision sys.tinyint,
709-
out_scale sys.tinyint,
710-
out_collation_name sys.sysname,
711-
out_collation_id int,
712-
out_offset smallint,
713-
out_is_nullable sys.bit,
714-
out_is_ansi_padded sys.bit,
715-
out_is_rowguidcol sys.bit,
716-
out_is_identity sys.bit,
717-
out_is_computed sys.bit,
718-
out_is_filestream sys.bit,
719-
out_is_replicated sys.bit,
720-
out_is_non_sql_subscribed sys.bit,
721-
out_is_merge_published sys.bit,
722-
out_is_dts_replicated sys.bit,
723-
out_is_xml_document sys.bit,
724-
out_xml_collection_id int,
725-
out_default_object_id int,
726-
out_rule_object_id int,
727-
out_is_sparse sys.bit,
728-
out_is_column_set sys.bit,
729-
out_generated_always_type sys.tinyint,
730-
out_generated_always_type_desc sys.nvarchar(60),
731-
out_encryption_type int,
732-
out_encryption_type_desc sys.nvarchar(64),
733-
out_encryption_algorithm_name sys.sysname,
734-
out_column_encryption_key_id int,
735-
out_column_encryption_key_database_name sys.sysname,
736-
out_is_hidden sys.bit,
737-
out_is_masked sys.bit,
738-
out_graph_type int,
739-
out_graph_type_desc sys.nvarchar(60)
740-
)
741-
AS
742-
$$
743-
744698
CREATE OR REPLACE FUNCTION sys.columns_internal()
745699
RETURNS TABLE (
746700
out_object_id int,

contrib/babelfishpg_tsql/src/hooks.c

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3533,16 +3533,32 @@ pltsql_report_proc_not_found_error(List *names, List *fargs, List *given_argname
35333533
}
35343534

35353535
if (!has_default)
3536+
{
3537+
const char *display_name = p_argnames[pp];
3538+
char *orig = lookup_bbf_ident_mapping(p_argnames[pp],
3539+
get_namespace_name(procform->pronamespace),
3540+
ProcedureRelationId,
3541+
NameStr(procform->proname));
3542+
if (orig)
3543+
display_name = orig;
35363544
ereport(ERROR,
35373545
(errcode(ERRCODE_UNDEFINED_FUNCTION),
3538-
errmsg("%s %s expects parameter \"%s\", which was not supplied.", obj_type, NameListToString(names), p_argnames[pp])),
3546+
errmsg("%s %s expects parameter \"%s\", which was not supplied.", obj_type, NameListToString(names), display_name)),
35393547
parser_errposition(pstate, location));
3548+
}
35403549
}
35413550
else if (pp < first_arg_with_default)
35423551
{
3552+
const char *display_name = p_argnames[pp];
3553+
char *orig = lookup_bbf_ident_mapping(p_argnames[pp],
3554+
get_namespace_name(procform->pronamespace),
3555+
ProcedureRelationId,
3556+
NameStr(procform->proname));
3557+
if (orig)
3558+
display_name = orig;
35433559
ereport(ERROR,
35443560
(errcode(ERRCODE_UNDEFINED_FUNCTION),
3545-
errmsg("%s %s expects parameter \"%s\", which was not supplied.", obj_type, NameListToString(names), p_argnames[pp])),
3561+
errmsg("%s %s expects parameter \"%s\", which was not supplied.", obj_type, NameListToString(names), display_name)),
35463562
parser_errposition(pstate, location));
35473563
}
35483564
}
@@ -5576,13 +5592,23 @@ replace_pltsql_function_defaults(HeapTuple func_tuple, List *defaults, List *far
55765592
}
55775593
if (!has_default)
55785594
{
5595+
const char *display_name;
5596+
char *orig;
5597+
55795598
arg_names = fetch_func_input_arg_names(func_tuple);
5599+
display_name = arg_names[i];
5600+
orig = lookup_bbf_ident_mapping(arg_names[i],
5601+
get_namespace_name(proc_form->pronamespace),
5602+
ProcedureRelationId,
5603+
NameStr(proc_form->proname));
5604+
if (orig)
5605+
display_name = orig;
55805606

55815607
if (proc_form->prokind == PROKIND_PROCEDURE)
55825608
ereport(ERROR,
55835609
(errcode(ERRCODE_UNDEFINED_FUNCTION),
55845610
errmsg("Procedure or function \'%s\' expects parameter \'%s\', which was not supplied.",
5585-
NameStr(proc_form->proname), arg_names[i])));
5611+
NameStr(proc_form->proname), display_name)));
55865612
}
55875613
++i;
55885614
}

contrib/babelfishpg_tsql/src/pltsql.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,6 @@ typedef struct PLtsql_variable
389389
PLtsql_datum_type dtype;
390390
int dno;
391391
char *refname;
392-
char *original_name;
393392
int lineno;
394393
bool isconst;
395394
bool notnull;
@@ -414,7 +413,6 @@ typedef struct PLtsql_var
414413
PLtsql_datum_type dtype;
415414
int dno;
416415
char *refname;
417-
char *original_name;
418416
int lineno;
419417
bool isconst;
420418
bool notnull;
@@ -474,7 +472,6 @@ typedef struct PLtsql_row
474472
PLtsql_datum_type dtype;
475473
int dno;
476474
char *refname;
477-
char *original_name;
478475
int lineno;
479476
bool isconst;
480477
bool notnull;
@@ -503,7 +500,6 @@ typedef struct PLtsql_rec
503500
PLtsql_datum_type dtype;
504501
int dno;
505502
char *refname;
506-
char *original_name;
507503
int lineno;
508504
bool isconst;
509505
bool notnull;

contrib/babelfishpg_tsql/src/tsqlIface.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5982,7 +5982,6 @@ makeDeclareStmt(TSqlParser::Declare_statementContext *ctx, std::map<PLtsql_stmt
59825982
PLtsql_type *type = parse_datatype(typeStr.c_str(), 0);
59835983

59845984
PLtsql_variable *var = pltsql_build_variable(name, 0, type, true);
5985-
var->original_name = pstrdup(nameStr.c_str());
59865985

59875986
result.push_back(makeDeclTableStmt(var, type, getLineNo(ctx)));
59885987
}
@@ -6002,7 +6001,6 @@ makeDeclareStmt(TSqlParser::Declare_statementContext *ctx, std::map<PLtsql_stmt
60026001
{
60036002
// cursor datatype needs a special build process
60046003
var = (PLtsql_variable *) build_cursor_variable(name, getLineNo(local));
6005-
var->original_name = pstrdup(nameStr.c_str());
60066004
}
60076005
else
60086006
{
@@ -6016,7 +6014,6 @@ makeDeclareStmt(TSqlParser::Declare_statementContext *ctx, std::map<PLtsql_stmt
60166014

60176015
var = pltsql_build_variable(name, 0, type, true);
60186016

6019-
var->original_name = pstrdup(nameStr.c_str());
60206017

60216018
if (var->dtype == PLTSQL_DTYPE_TBL)
60226019
result.push_back(makeDeclTableStmt(var, type, getLineNo(ctx)));

test/JDBC/expected/long-identifiers-error-messages.out

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,65 @@ GO
637637

638638
~~ERROR (Message: The database 'nonexistent_very_long_database_name_that_exceeds_postgresql_limit_of_sixty_three_chars' does not exist. Supply a valid database name. To see available databases, use sys.databases.)~~
639639

640+
641+
642+
-- ===========================================
643+
-- Table variable errors
644+
-- ===========================================
645+
-- First batch declares (populates cache), second batch references (triggers error with full name)
646+
DECLARE @Very_Long_Table_Variable_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Characters TABLE (id INT);
647+
GO
648+
SELECT * FROM @Very_Long_Table_Variable_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Characters;
649+
GO
650+
~~ERROR (Code: 33557097)~~
651+
652+
~~ERROR (Message: relation "@very_long_table_variable_name_that_exceeds_postgresql_limit_of_sixty_three_characters" does not exist)~~
653+
654+
655+
-- ===========================================
656+
-- Parameter name display in error messages
657+
-- ===========================================
658+
-- Function with long parameter name - missing required param shows full name
659+
CREATE FUNCTION ErrTest_Func_Long_Param(@Very_Long_Parameter_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Characters INT) RETURNS INT AS BEGIN RETURN @Very_Long_Parameter_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Characters END;
660+
GO
661+
SELECT dbo.ErrTest_Func_Long_Param();
662+
GO
663+
~~ERROR (Code: 201)~~
664+
665+
~~ERROR (Message: function master_dbo.errtest_func_long_param expects parameter "@Very_Long_Parameter_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Characters", which was not supplied.)~~
666+
667+
668+
-- Procedure with long parameter name - missing required param shows full name
669+
CREATE PROCEDURE ErrTest_Proc_Long_Param @Very_Long_Parameter_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Characters INT AS SELECT @Very_Long_Parameter_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Characters;
670+
GO
671+
EXEC ErrTest_Proc_Long_Param;
672+
GO
673+
~~ERROR (Code: 201)~~
674+
675+
~~ERROR (Message: procedure errtest_proc_long_param expects parameter "@Very_Long_Parameter_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Characters", which was not supplied.)~~
676+
677+
678+
-- Procedure with long TVP parameter name - missing required param shows full name
679+
CREATE TYPE ErrTest_TVP_Type AS TABLE (id INT);
680+
GO
681+
CREATE PROCEDURE ErrTest_Proc_Long_TVP_Param @Very_Long_TVP_Parameter_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Characters ErrTest_TVP_Type READONLY AS SELECT * FROM @Very_Long_TVP_Parameter_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Characters;
682+
GO
683+
EXEC ErrTest_Proc_Long_TVP_Param;
684+
GO
685+
~~ERROR (Code: 201)~~
686+
687+
~~ERROR (Message: procedure errtest_proc_long_tvp_param expects parameter "@Very_Long_TVP_Parameter_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Characters", which was not supplied.)~~
688+
689+
690+
DROP FUNCTION ErrTest_Func_Long_Param;
691+
GO
692+
DROP PROCEDURE ErrTest_Proc_Long_Param;
693+
GO
694+
DROP PROCEDURE ErrTest_Proc_Long_TVP_Param;
695+
GO
696+
DROP TYPE ErrTest_TVP_Type;
697+
GO
698+
640699
-- CLEANUP
641700
-- ===========================================
642701
DROP INDEX ErrTest_Very_Long_Index_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Characters
@@ -655,5 +714,7 @@ DROP FUNCTION ErrTest_Very_Long_Function_Name_That_Exceeds_PostgreSQL_Limit_Of_S
655714
GO
656715
DROP PROCEDURE ErrTest_Very_Long_Procedure_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Chars;
657716
GO
717+
DROP PROCEDURE ErrTest_Proc_Constraint;
718+
GO
658719
DROP TYPE ErrTest_Very_Long_Type_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Characters;
659720
GO

test/JDBC/expected/long-identifiers.out

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,6 @@ GO
476476
~~START~~
477477
varchar#!#nvarchar
478478
Very_Long_Table_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Chars_For_Testing#!#USER_TABLE
479-
Very_Long_Function_Test_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Characters#!#SQL_SCALAR_FUNCTION
480479
Very_Long_Function_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Chars_For_Testing#!#SQL_SCALAR_FUNCTION
481480
~~END~~
482481

@@ -495,7 +494,6 @@ GO
495494
~~START~~
496495
nvarchar
497496
Very_Long_Function_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Chars_For_Testing
498-
Very_Long_Function_Test_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Characters
499497
Very_Long_Procedure_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Chars_For_Testing
500498
Very_Long_Trigger_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Chars_For_Testing
501499
~~END~~

test/JDBC/input/long-identifiers-error-messages.sql

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,49 @@ GO
423423

424424
CREATE LOGIN babel5975_test_long_login_name_that_exceeds_postgresql_limit_of_sixty_three_chars WITH PASSWORD = '12345678', DEFAULT_DATABASE = nonexistent_very_long_database_name_that_exceeds_postgresql_limit_of_sixty_three_chars;
425425
GO
426+
427+
-- ===========================================
428+
-- Table variable errors
429+
-- ===========================================
430+
431+
-- First batch declares (populates cache), second batch references (triggers error with full name)
432+
DECLARE @Very_Long_Table_Variable_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Characters TABLE (id INT);
433+
GO
434+
SELECT * FROM @Very_Long_Table_Variable_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Characters;
435+
GO
436+
-- ===========================================
437+
-- Parameter name display in error messages
438+
-- ===========================================
439+
440+
-- Function with long parameter name - missing required param shows full name
441+
CREATE FUNCTION ErrTest_Func_Long_Param(@Very_Long_Parameter_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Characters INT) RETURNS INT AS BEGIN RETURN @Very_Long_Parameter_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Characters END;
442+
GO
443+
SELECT dbo.ErrTest_Func_Long_Param();
444+
GO
445+
446+
-- Procedure with long parameter name - missing required param shows full name
447+
CREATE PROCEDURE ErrTest_Proc_Long_Param @Very_Long_Parameter_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Characters INT AS SELECT @Very_Long_Parameter_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Characters;
448+
GO
449+
EXEC ErrTest_Proc_Long_Param;
450+
GO
451+
452+
-- Procedure with long TVP parameter name - missing required param shows full name
453+
CREATE TYPE ErrTest_TVP_Type AS TABLE (id INT);
454+
GO
455+
CREATE PROCEDURE ErrTest_Proc_Long_TVP_Param @Very_Long_TVP_Parameter_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Characters ErrTest_TVP_Type READONLY AS SELECT * FROM @Very_Long_TVP_Parameter_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Characters;
456+
GO
457+
EXEC ErrTest_Proc_Long_TVP_Param;
458+
GO
459+
460+
DROP FUNCTION ErrTest_Func_Long_Param;
461+
GO
462+
DROP PROCEDURE ErrTest_Proc_Long_Param;
463+
GO
464+
DROP PROCEDURE ErrTest_Proc_Long_TVP_Param;
465+
GO
466+
DROP TYPE ErrTest_TVP_Type;
467+
GO
468+
426469
-- CLEANUP
427470
-- ===========================================
428471
DROP INDEX ErrTest_Very_Long_Index_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Characters
@@ -441,5 +484,7 @@ DROP FUNCTION ErrTest_Very_Long_Function_Name_That_Exceeds_PostgreSQL_Limit_Of_S
441484
GO
442485
DROP PROCEDURE ErrTest_Very_Long_Procedure_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Chars;
443486
GO
487+
DROP PROCEDURE ErrTest_Proc_Constraint;
488+
GO
444489
DROP TYPE ErrTest_Very_Long_Type_Name_That_Exceeds_PostgreSQL_Limit_Of_Sixty_Three_Characters;
445490
GO

0 commit comments

Comments
 (0)