cancel
Showing results for 
Search instead for 
Did you mean: 

Permissions in SQL Anywhere 12 Strange Behavior

JimDiaz
Participant
2,769

There is a seemingly a bug in SQL Anywhere 12 associated with permissions. The details are a bit long winded so I have posted a script here for those of you who are curious enough to download and take a look. To see the problem create a 12 database and execute the updated script I have posted, then log in as dba password sql and execute the command CALL AP2.SelectsFromJoinedTablesProcedure. You will receive the error "Permission denied: you do not have permission to select from "TableOne"

The exact same scenario is duplicated in this script but without a join in the underlying table this can be tested by executing the command CALL AP2.SelectsFromSingleTableProcedure. No errors are reported.

link text

Thanks,

Jim

Accepted Solutions (0)

Answers (1)

Answers (1)

jeff_albion
Product and Topic Expert
Product and Topic Expert

Yes, I can reproduce this issue ("Permission denied: you do not have permission to select from "TableOne"), and will confirm there's some type of bug here with how we annotate which permissions to grant from the execute procedure as invoker/definer from your sample:

DBA -> AP2.SelectsFromJoinedTablesProcedure -> AP1.SelectsFromJoinedTables -> AP1.Tables

This has now been reported as CR #748096. The issue can currently be worked around by either executing:

GRANT SELECT ON AP1.TableOne TO AP2
go

or by simply re-writing the JOIN to another format (using KEY JOIN or re-writing to use a WHERE clause will work, but INNER JOIN causes the error to be thrown):

BEGIN
    SELECT TableTwo.PrimaryKeyColumn,
         TableTwo.ForeignKeyColumn,
         TableOne.ColumnOne,
         TableTwo.ColumnTwo
    FROM AP1.TableOne KEY JOIN AP1.TableTwo;
END
go
JimDiaz
Participant
0 Kudos

Thanks for the verification. Our tests show that KEY JOIN does not work around the issue.

jeff_albion
Product and Topic Expert
Product and Topic Expert
0 Kudos

How about using a WHERE clause instead? That worked to resolve the issue also in my test:

FROM AP1.TableOne, AP2.TableTwo WHERE TableOne.PrimaryKeyColumn = TableTwo.ForeignKeyColumn;

Which version and build of SQL Anywhere are you using to test with?

JimDiaz
Participant
0 Kudos

just tried and yes that worked so did FROM AP1.TableTwo JOIN AP1.TableOne ON TableTwo.ForeignKeyColumn = TableOne.PrimaryKeyColumn I am issuing ALTER FUNCTION "AP2"."SelectsFromJoinedTablesProcedure" RECOMPILE between changes. Using 12.0.1 build 3750